I'm looking for a way to populate some feature attributes via API during digitization of FDO features (on a Shapefile layer). Alternatively, also setting the attributes on check-in would be ok.
What I have tried so far:
Dim map As AcMapMap = AcMapMap.GetCurrentMap() AddHandler map.FeatureInstanceToBeAdded, AddressOf FeatureInstanceToBeAdded AddHandler map.FeatureInstanceAdded, AddressOf FeatureInstanceAdded Dim doc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument doc.SendStringToExecute("-MAPLINESTRINGCREATE ""Forced Feeder Cables"" ", False, False, True)
Unfortunately, in the 2 events I only get a System.IntPtr object as the sender and in the event arguments only the layer + session ID, so I don't see a way there to modify attributes of the new feature.
Second approach:
Dim service As Autodesk.Gis.Map.Platform.Internal.AcMapEditingService = Autodesk.Gis.Map.Platform.Internal.AcMapEditingService.GetInstance() Dim options As New Autodesk.Gis.Map.Platform.Internal.AcMapFeatureAcquisitionOptions() options.AcquireStylized = True options.GeometryPropertyName = _layer.GetClassDefinition().DefaultGeometryPropertyName options.HasM = False options.HasZ = False Dim propCol As New MgPropertyCollection()
propCol.Add(New MgInt32Property("MyProp", 123)) service.AcquireLineString(_layer, propCol, "Digitize line string", options)
Sounds and looks very promising, digitization starts but then no feature is written.
What is the right way to do this? Any advice is highly appreciated!
Best regards,
Thomas
Solved! Go to Solution.
Solved by thkoehler. Go to Solution.
Never mind, method 2 is working now. I was assuming that AcMapEditingService.AcquireLinestring automatically writes the feature to the layer. But instead, it only adds the geometry property to the MgPropertyCollection. Now I'm manually inserting the feature using a MgInsertFeatures command and that works like a charm :).
Hi,
there is some sample code by ADN:
Rob
Hi Rob,
I had seen that blog post, however it is about digitizing points and for the digitize operation it is using the Editor.GetPoint method from the AutoCAD API. Unfortunately, I didn't find a similar method in the AutoCAD API for digitizing line strings (there is no such thing as Editor.GetLinestring()) and I didn't want to create that on my own, so I was looking for some alternative approaches :).
Best regards,
Thomas