POST
|
richwawr, thank you for help. I found working example for this question. IApplication m_application; public frmSetHeight() { InitializeComponent(); } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } private void btnOK_Click(object sender, EventArgs e) { m_application = AddHeight.ArcScene.Application; ISxDocument pDoc = ArcScene.Document; IFeatureLayer pFtrLyr = GetCurrentFeatyreLayer(); IFeatureSelection pFtrSel = pFtrLyr as IFeatureSelection; IQueryFilter pFilter = new QueryFilterClass(); pFilter.WhereClause = ""; ICursor cursor; pFtrSel.SelectionSet.Search(pFilter, false, out cursor); IFeatureCursor pFtrCsr = cursor as IFeatureCursor; IFeature pFtr = pFtrCsr.NextFeature(); while(pFtr != null) { ITransform3D trans3D = pFtr.Shape as ITransform3D; double dx = 0; double dy = 0; double dz = Convert.ToDouble(textBox1.Text); trans3D.Move3D(dx, dy,dz); pFtr.Store(); pFtr = pFtrCsr.NextFeature(); } pDoc.Scene.SceneGraph.Invalidate (pFtrLyr, true, true ); pDoc.Scene.SceneGraph.RefreshViewers(); } private IFeatureLayer GetCurrentFeatyreLayer() { var pLayer = ((ISxDocument)m_application.Document).SelectedLayer; return pLayer as IFeatureLayer; }
... View more
06-17-2012
03:49 AM
|
0
|
0
|
874
|
POST
|
Oh, ok, IGeometryBridge more hardest. Please see that, i think, error in function call.
IPolyline pl = null;
IFeature feature;
pl = (IPolyline)feature.Shape;
feature.Shape = ModifyVertexOfAPolyline((IGeometryCollection)pl);
ModifyVertexOfAPolyline:
private IPolyline ModifyFirstVertexOfAPolyline(IGeometryCollection gcPolyline)
{
int hitPartIndex = 0;
hitPartIndex = gcPolyline.GeometryCount;
hitPartIndex--;
IGeometry geometry = gcPolyline.get_Geometry(hitPartIndex);
var pointCollection = (IPointCollection4)geometry;
int indextransformPoint = 1;
indextransformPoint = pointCollection.PointCount;
MessageBox.Show("indexTransformPoint = " + indextransformPoint.ToString() +
"\nhitPartIndex = " + hitPartIndex.ToString());
indextransformPoint--;
Double zOffset = Convert.ToDouble( textBox3.Text);
if (zOffset == 0 )
return gcPolyline as IPolyline;
IPoint TestPoint;
TestPoint = pointCollection.get_Point(indextransformPoint);
IZAware zAware = TestPoint as IZAware;
zAware.ZAware = true;
TestPoint.X = pointCollection.get_Point(indextransformPoint).X;
TestPoint.Y = pointCollection.get_Point(indextransformPoint).Y;
TestPoint.Z = pointCollection.get_Point(indextransformPoint).Z + zOffset;
var transform3D = (ITransform3D)TestPoint;
transform3D.Move3D(0, 0, zOffset);
TestPoint = (IPoint)transform3D;
var newTestPoint = (IPoint)transform3D;
pointCollection.UpdatePoint(indextransformPoint, TestPoint);
MessageBox.Show(pointCollection.get_Point(indextransformPoint).Z.ToString());
m_application.RefreshWindow();
return pointCollection as IPolyline;
}
I am so stupid in this SDK, sorry... -------------------Added------------------- Top code example updated. This is "new" version:
IPolyline pl = null;
IFeature feature;
pl = (IPolyline)feature.Shape;
feature.Shape = ModifyVertexOfAPolyline((IGeometryCollection)pl);
feature.Store();
After execute this, all selected shapes rewrited to this: [ATTACH=CONFIG]15185[/ATTACH] In identify window: [ATTACH=CONFIG]15186[/ATTACH]
... View more
06-13-2012
10:16 AM
|
0
|
0
|
874
|
POST
|
Hmm, doesn't work too. And another question, how to use IGeometryBridge? Please see code in previous post. It's correct? I think, i may use this method.
... View more
06-12-2012
11:50 AM
|
0
|
0
|
874
|
POST
|
int hitPartIndex = 0;
hitPartIndex = gcPolyline.GeometryCount;
hitPartIndex--;
IGeometry geometry = gcPolyline.get_Geometry(hitPartIndex);
var pointCollection = (IPointCollection4)geometry;
int indextransformPoint = 1;
indextransformPoint = pointCollection.PointCount;
MessageBox.Show("indexTransformPoint = " + indextransformPoint.ToString() +
"\nhitPartIndex = " + hitPartIndex.ToString());
indextransformPoint--;
Double zOffset = Convert.ToDouble( textBox3.Text);
MessageBox.Show("zOffset = " + textBox3.Text);
if (zOffset == 0 )
return gcPolyline as IPolyline;
IPoint TestPoint;
TestPoint = pointCollection.get_Point(indextransformPoint);
TestPoint.X = pointCollection.get_Point(indextransformPoint).X;
TestPoint.Y = pointCollection.get_Point(indextransformPoint).Y;
TestPoint.Z = pointCollection.get_Point(indextransformPoint).Z + zOffset;
var transform3D = (ITransform3D)TestPoint;
transform3D.Move3D(0, 0, zOffset);
var newTestPoint = (IPoint)transform3D;
IZAware zAware = newTestPoint as IZAware;
zAware.ZAware = true;
pointCollection.UpdatePoint(indextransformPoint, newTestPoint);
MessageBox.Show(pointCollection.get_Point(indextransformPoint).Z.ToString());
m_application.RefreshWindow(); Doesn't work 😞 And, for example, i use IGeometryBridge:
IPoint[] array = new IPoint[1];
array[0] = newTestPoint;
IGeometryBridge testBridge = new GeometryEnvironmentClass();
//MessageBox.Show("until testBridge");
try
{
testBridge.ReplacePoints(pointCollection, 0, 1, array);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
//MessageBox.Show("after testBridge");
But here i see only Exception errors...
... View more
06-12-2012
11:15 AM
|
0
|
0
|
874
|
POST
|
int hitPartIndex; hitPartIndex = gcPolyline.GeometryCount; hitPartIndex--; IGeometry geometry = gcPolyline.get_Geometry(hitPartIndex); var pointCollection = (IPointCollection4)geometry; int indextransformPoint; indextransformPoint = pointCollection.PointCount; indextransformPoint--; Double zOffset = Convert.ToDouble( textBox3.Text); MessageBox.Show("zOffset = " + textBox3.Text); if (zOffset == 0 ) return gcPolyline as IPolyline; IPoint TestPoint; TestPoint = pointCollection.get_Point(0); TestPoint.X = pointCollection.get_Point(0).X; TestPoint.Y = pointCollection.get_Point(0).Y; TestPoint.Z = pointCollection.get_Point(0).Z + zOffset; MessageBox.Show("test.z = " + TestPoint.Z.ToString()); var transform3D = (ITransform3D)TestPoint; transform3D.Move3D(0, 0, zOffset); pointCollection.UpdatePoint(indextransformPoint, TestPoint); Here i have 2 message boxes. First: zOffset = 150. Second: test.z = 223. But in selected polyline Z-value not change, why?
... View more
06-11-2012
11:56 PM
|
0
|
7
|
2408
|
POST
|
For examle, i have attribute table with very many rows. How to get object ID from selected rows in this table?
... View more
05-15-2012
11:16 AM
|
0
|
1
|
405
|
POST
|
private void button2_Click(object sender, EventArgs e) { IEditor m_editor; m_application = ArcSceneAddin1.ArcScene.Application; edUID.Value = "esriEditor.Editor"; m_editor = m_application.FindExtensionByCLSID(edUID) as IEditor; IEditSketch3 edSketch = m_editor as IEditSketch3; int selectedvertexcount; selectedvertexcount = edSketch.SelectedVertexCount; IPointCollection4 ptColl = edSketch.Geometry as IPointCollection4; ISketchOperation2 sketchOp = new SketchOperationClass(); sketchOp.Start(m_editor); IPoint pt = ptColl.get_Point(0); if (radioButton1.Checked) { for (int i = 0; i < ptColl.PointCount; i++) { pt = ptColl.get_Point(i); IPoint pt_c = pt; pt_c.Z = height; ptColl.UpdatePoint(i, pt_c); }; //constant }; if (radioButton2.Checked) { for (int i = 0; i < ptColl.PointCount; i++) { pt = ptColl.get_Point(i); IPoint pt_c = pt; pt_c.Z += height; ptColl.UpdatePoint(i, pt_c); }; //add to current height }; sketchOp.MenuString = "height change to selected object."; edSketch.Geometry = ptColl as IGeometry; sketchOp.Finish(edSketch.Geometry.Envelope, esriSketchOperationType.esriSketchOperationVertexDeleted, pt); } Thx for help, ESRI community...
... View more
05-13-2012
02:37 PM
|
0
|
0
|
301
|
POST
|
private void button2_Click(object sender, EventArgs e)
{
IEditor m_editor;
m_application = ArcSceneAddin1.ArcScene.Application;
UIDClass edUID = new UIDClass();
edUID.Value = "esriEditor.Editor";
m_editor = m_application.FindExtensionByCLSID(edUID) as IEditor;
IEditSketch3 edSketch = m_editor as IEditSketch3;
int selectedvertexcount;
selectedvertexcount = edSketch.SelectedVertexCount;
MessageBox.Show("SelectedVertexCount = " + selectedvertexcount.ToString() + "\nLastPoint.Z = " + edSketch.LastPoint.Z);
edSketch.LastPoint.Z = 145;
} Here LastPoint.Z = 146. But edSketch.LastPoint.Z = 145; not change this value... And yes, after pressing to 'Button2' i see error "Unable to save document" when i close ArcScene with saving.
... View more
05-13-2012
01:41 PM
|
0
|
0
|
301
|
POST
|
How to edit sketch properties (Lines or Points)? I need change Z-value in selected objects with C#, but don't know how.
... View more
05-10-2012
11:31 PM
|
0
|
2
|
920
|
POST
|
Hello. I need rotate selected object in multipatch layer. I found one example, but it does not suit me. Private Sub CommandButton1_Click()
Dim pUID As New UID
Dim pCmdItem As ICommandItem
pUID.Value = "esriEditor.StartEditingCommand"
Set pCmdItem = Application.Document.CommandBars.Find(pUID)
pCmdItem.Execute
pUID.Value = "esri3DAnalystUI.Rotate3DCommand"
Set pCmdItem = Application.Document.CommandBars.Find(pUID)
pCmdItem.Execute
End Sub After clicking to Button1 opens window and wait for entered value. I do not need this screen. After clicking i need rotate object to, for example, 5 degree (this value will be constant).
... View more
04-17-2012
02:03 PM
|
0
|
0
|
359
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|