Hello all,
I'm currently working on an AutoCAD plugin in VB.net to utilize the "MapConnect" command, linked to around 70+ *.SHP files, to convert them to ACAD objects, while maintaining a list to conditionalize for later use as the values my differ. As we all know, Feature Data Objects (FDO) are not native to the ACAD IDE, which is why I've utilized the "Autodesk.Gis.Map.Platform" API (With a bit of a learning curve, I might add). I'm very proficient in Autolisp/VisualLisp, but have yet to come a solution for extracting the geometry of each selected FDO object. So far I have been able to compile a DLL in Visual Studio to, recursively, print the following. Layer, PropertyName, and the Value of each object, no matter the amount of properties in each object using the PropertyCount in a variable "Top". The following represents the output when passed to the command line:
Command: atr
Select Feature Data Objects in Map 3D: 1 found
Select Feature Data Objects in Map 3D:
7OF_OWNER_PubData_Parcels_Lay-OBJECTID-137937
9OF_OWNER_PubData_Parcels_Lay-PIN-0130300049
5OF_OWNER_PubData_Parcels_Lay-ACREAGE-92.9
9OF_OWNER_PubData_Parcels_Lay-ACRE_SOURC-Calculated
9OF_OWNER_PubData_Parcels_Lay-PARCEL_STA-Approved
5OF_OWNER_PubData_Parcels_Lay-TXT_ANGLE-0
5OF_OWNER_PubData_Parcels_Lay-SHAPE_Leng-0
7OF_OWNER_PubData_Parcels_Lay-ID-0
9OF_OWNER_PubData_Parcels_Lay-Field1-Null
9OF_OWNER_PubData_Parcels_Lay-Field2-Null
9OF_OWNER_PubData_Parcels_Lay-Field3-Null
9OF_OWNER_PubData_Parcels_Lay-Field4-Null
9OF_OWNER_PubData_Parcels_Lay-Field5-Null
9OF_OWNER_PubData_Parcels_Lay-Field6-Null
9OF_OWNER_PubData_Parcels_Lay-Field7-Null
9OF_OWNER_PubData_Parcels_Lay-Field10-Null
9OF_OWNER_PubData_Parcels_Lay-Field8-Null
5OF_OWNER_PubData_Parcels_Lay-Shape_STAr-679565.625
5OF_OWNER_PubData_Parcels_Lay-Shape_STLe-4492.44725671
13OF_OWNER_PubData_Parcels_Lay-Geometry-OSGeo.MapGuide.MgByteReader
All this to say, I'm not quite sure how to access the underlying data of geometry as it shows up as OSGeo.MapGuide.MgByteReader, which appears to be a collection in the properties tabs. I'm very new to this API and VB.net, so any help is appreciated! Also I've attached my code below, not including the references:
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.Gis.Map.Platform
Imports Autodesk.Gis.Map.Platform.Interop
Imports OSGeo.MapGuide
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Namespace FDOAttributes
Public Class myCommands
<CommandMethod("atr")>
Public Shared Sub Get_Selection()
Dim Cur_Map As AcMapMap = AcMapMap.GetCurrentMap()
Dim Map_Layers As MgLayerCollection = Cur_Map.GetLayers()
Dim Prompt_Sel_OP As PromptSelectionOptions = New PromptSelectionOptions()
Prompt_Sel_OP.MessageForAdding = "Select Feature Data Objects in Map 3D: "
Prompt_Sel_OP.SingleOnly = False
Dim Prompt_Sel_Res As PromptSelectionResult = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(Prompt_Sel_OP)
Try
If Prompt_Sel_Res.Status = PromptStatus.OK Then
Dim Selection_All As SelectionSet = Prompt_Sel_Res.Value
Dim Obj_Array() As ObjectId = Prompt_Sel_Res.Value.GetObjectIds()
Dim Obj_Arr_Top As Integer = Obj_Array.Length
Dim Progress As ProgressMeter = New ProgressMeter
Progress.Start("Analyzing Feature Data Objects: ")
Progress.SetLimit(Obj_Arr_Top)
Progress.Start()
For Each Obj_Id As ObjectId In Obj_Array
Progress.MeterProgress()
Dim Map_Selection_Base As MgSelectionBase = AcMapFeatureEntityService.GetSelection(Selection_All)
Dim Map_Layer As AcMapLayer = AcMapFeatureEntityService.GetLayer(Obj_Id)
Dim Feature_Reader As MgFeatureReader = Map_Selection_Base.GetSelectedFeatures(Map_Layer, Map_Layer.FeatureClassName, False)
Dim top As Integer = Feature_Reader.GetPropertyCount
Dim Tag As String
Dim Property_Type As Integer
Dim Field_Value
Dim Obj_Layer As String
While Feature_Reader.ReadNext
For index As Integer = 1 To top - 1
Tag = Feature_Reader.GetPropertyName(index).ToString
Property_Type = Feature_Reader.GetPropertyType(Tag)
Obj_Layer = AcMapFeatureEntityService.GetLayer(Obj_Id).Name.ToString
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(Property_Type.ToString)
Dim Class_Def As MgClassDefinition = Feature_Reader.GetClassDefinition()
Dim isNull As Boolean = Feature_Reader.IsNull(Tag)
If Property_Type = MgPropertyType.Double AndAlso isNull = False Then
Field_Value = Feature_Reader.GetDouble(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Int16 AndAlso isNull = False Then
Field_Value = Feature_Reader.GetInt16(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Int32 AndAlso isNull = False Then
Field_Value = Feature_Reader.GetInt32(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Int64 AndAlso isNull = False Then
Field_Value = Feature_Reader.GetInt64(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Single AndAlso isNull = False Then
Field_Value = Feature_Reader.GetSingle(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.String AndAlso isNull = False Then
Field_Value = Feature_Reader.GetString(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Blob AndAlso isNull = False Then
Field_Value = Feature_Reader.GetBLOB(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Boolean AndAlso isNull = False Then
Field_Value = Feature_Reader.GetBoolean(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Byte AndAlso isNull = False Then
Field_Value = Feature_Reader.GetByte(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Clob AndAlso isNull = False Then
Field_Value = Feature_Reader.GetCLOB(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.DateTime AndAlso isNull = False Then
Field_Value = Feature_Reader.GetDateTime(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Feature AndAlso isNull = False Then
Field_Value = Feature_Reader.GetFeatureObject(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Geometry AndAlso isNull = False Then
Field_Value = Feature_Reader.GetGeometry(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Raster AndAlso isNull = False Then
Field_Value = Feature_Reader.GetRaster(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
Else
Field_Value = "Null"
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
End If
Next
End While
Next
Progress.Stop()
End If
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction.Commit()
Catch e As Exception
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.ToString & vbCrLf)
End Try
End Sub
Public Shared Sub Test_Property_Values(Value As String, Layer As String, Prop As String)
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(Layer & "-" & Prop & "-" & Value & vbCrLf)
End Sub
End Class
End Namespace
Thanks in Advance!
Michael Luckett
Solved! Go to Solution.
Hello all,
I'm currently working on an AutoCAD plugin in VB.net to utilize the "MapConnect" command, linked to around 70+ *.SHP files, to convert them to ACAD objects, while maintaining a list to conditionalize for later use as the values my differ. As we all know, Feature Data Objects (FDO) are not native to the ACAD IDE, which is why I've utilized the "Autodesk.Gis.Map.Platform" API (With a bit of a learning curve, I might add). I'm very proficient in Autolisp/VisualLisp, but have yet to come a solution for extracting the geometry of each selected FDO object. So far I have been able to compile a DLL in Visual Studio to, recursively, print the following. Layer, PropertyName, and the Value of each object, no matter the amount of properties in each object using the PropertyCount in a variable "Top". The following represents the output when passed to the command line:
Command: atr
Select Feature Data Objects in Map 3D: 1 found
Select Feature Data Objects in Map 3D:
7OF_OWNER_PubData_Parcels_Lay-OBJECTID-137937
9OF_OWNER_PubData_Parcels_Lay-PIN-0130300049
5OF_OWNER_PubData_Parcels_Lay-ACREAGE-92.9
9OF_OWNER_PubData_Parcels_Lay-ACRE_SOURC-Calculated
9OF_OWNER_PubData_Parcels_Lay-PARCEL_STA-Approved
5OF_OWNER_PubData_Parcels_Lay-TXT_ANGLE-0
5OF_OWNER_PubData_Parcels_Lay-SHAPE_Leng-0
7OF_OWNER_PubData_Parcels_Lay-ID-0
9OF_OWNER_PubData_Parcels_Lay-Field1-Null
9OF_OWNER_PubData_Parcels_Lay-Field2-Null
9OF_OWNER_PubData_Parcels_Lay-Field3-Null
9OF_OWNER_PubData_Parcels_Lay-Field4-Null
9OF_OWNER_PubData_Parcels_Lay-Field5-Null
9OF_OWNER_PubData_Parcels_Lay-Field6-Null
9OF_OWNER_PubData_Parcels_Lay-Field7-Null
9OF_OWNER_PubData_Parcels_Lay-Field10-Null
9OF_OWNER_PubData_Parcels_Lay-Field8-Null
5OF_OWNER_PubData_Parcels_Lay-Shape_STAr-679565.625
5OF_OWNER_PubData_Parcels_Lay-Shape_STLe-4492.44725671
13OF_OWNER_PubData_Parcels_Lay-Geometry-OSGeo.MapGuide.MgByteReader
All this to say, I'm not quite sure how to access the underlying data of geometry as it shows up as OSGeo.MapGuide.MgByteReader, which appears to be a collection in the properties tabs. I'm very new to this API and VB.net, so any help is appreciated! Also I've attached my code below, not including the references:
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.Gis.Map.Platform
Imports Autodesk.Gis.Map.Platform.Interop
Imports OSGeo.MapGuide
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Namespace FDOAttributes
Public Class myCommands
<CommandMethod("atr")>
Public Shared Sub Get_Selection()
Dim Cur_Map As AcMapMap = AcMapMap.GetCurrentMap()
Dim Map_Layers As MgLayerCollection = Cur_Map.GetLayers()
Dim Prompt_Sel_OP As PromptSelectionOptions = New PromptSelectionOptions()
Prompt_Sel_OP.MessageForAdding = "Select Feature Data Objects in Map 3D: "
Prompt_Sel_OP.SingleOnly = False
Dim Prompt_Sel_Res As PromptSelectionResult = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(Prompt_Sel_OP)
Try
If Prompt_Sel_Res.Status = PromptStatus.OK Then
Dim Selection_All As SelectionSet = Prompt_Sel_Res.Value
Dim Obj_Array() As ObjectId = Prompt_Sel_Res.Value.GetObjectIds()
Dim Obj_Arr_Top As Integer = Obj_Array.Length
Dim Progress As ProgressMeter = New ProgressMeter
Progress.Start("Analyzing Feature Data Objects: ")
Progress.SetLimit(Obj_Arr_Top)
Progress.Start()
For Each Obj_Id As ObjectId In Obj_Array
Progress.MeterProgress()
Dim Map_Selection_Base As MgSelectionBase = AcMapFeatureEntityService.GetSelection(Selection_All)
Dim Map_Layer As AcMapLayer = AcMapFeatureEntityService.GetLayer(Obj_Id)
Dim Feature_Reader As MgFeatureReader = Map_Selection_Base.GetSelectedFeatures(Map_Layer, Map_Layer.FeatureClassName, False)
Dim top As Integer = Feature_Reader.GetPropertyCount
Dim Tag As String
Dim Property_Type As Integer
Dim Field_Value
Dim Obj_Layer As String
While Feature_Reader.ReadNext
For index As Integer = 1 To top - 1
Tag = Feature_Reader.GetPropertyName(index).ToString
Property_Type = Feature_Reader.GetPropertyType(Tag)
Obj_Layer = AcMapFeatureEntityService.GetLayer(Obj_Id).Name.ToString
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(Property_Type.ToString)
Dim Class_Def As MgClassDefinition = Feature_Reader.GetClassDefinition()
Dim isNull As Boolean = Feature_Reader.IsNull(Tag)
If Property_Type = MgPropertyType.Double AndAlso isNull = False Then
Field_Value = Feature_Reader.GetDouble(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Int16 AndAlso isNull = False Then
Field_Value = Feature_Reader.GetInt16(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Int32 AndAlso isNull = False Then
Field_Value = Feature_Reader.GetInt32(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Int64 AndAlso isNull = False Then
Field_Value = Feature_Reader.GetInt64(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Single AndAlso isNull = False Then
Field_Value = Feature_Reader.GetSingle(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.String AndAlso isNull = False Then
Field_Value = Feature_Reader.GetString(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Blob AndAlso isNull = False Then
Field_Value = Feature_Reader.GetBLOB(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Boolean AndAlso isNull = False Then
Field_Value = Feature_Reader.GetBoolean(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Byte AndAlso isNull = False Then
Field_Value = Feature_Reader.GetByte(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Clob AndAlso isNull = False Then
Field_Value = Feature_Reader.GetCLOB(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.DateTime AndAlso isNull = False Then
Field_Value = Feature_Reader.GetDateTime(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Feature AndAlso isNull = False Then
Field_Value = Feature_Reader.GetFeatureObject(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Geometry AndAlso isNull = False Then
Field_Value = Feature_Reader.GetGeometry(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
ElseIf Property_Type = MgPropertyType.Raster AndAlso isNull = False Then
Field_Value = Feature_Reader.GetRaster(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
Else
Field_Value = "Null"
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag)
End If
Next
End While
Next
Progress.Stop()
End If
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction.Commit()
Catch e As Exception
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.ToString & vbCrLf)
End Try
End Sub
Public Shared Sub Test_Property_Values(Value As String, Layer As String, Prop As String)
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(Layer & "-" & Prop & "-" & Value & vbCrLf)
End Sub
End Class
End Namespace
Thanks in Advance!
Michael Luckett
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
AutoCAD Map does provide command to convert map objects (FDO features) into native AutoCAD entities. However, it is unfortunate/shame that the Map platform APIs (now called Map geospatial APIs) does not provide API to do it. It is up to you, the programmer to invent your "own wheel": reading the MgGeometry's geometric data and generate corresponding native AutoCAD entities (polyline, arc, circle, point...), among them, generating polyline would be quite difficult code work on your own.
AutoCAD Map's Industrial Model APIs (IM APIs) include converting Feature geometrie to AutoCAD entities. But the Features in IM is different from Map Features, but at least you can learn from the sample code coming from IM.
With that said, since your goal is to bring data from *.shp file into AutoCAD as native AutoCAD entities (and the attribute data with these objects), you can do it much easier with AutoCAD MAP Import/Export APIs than using Platform API, where you need to convert the geometries with your own code. The AutoCAD Map Import/Export APIs do the same thing as you use command "MapImport" to import from SHP file.
So, if your goal is to learn and use Plafform APIs, go ahead with that. But if the goal is to bring data in SHP into AutoCAD, doing it with Map's Import/Export API would be easier and more pragmatic, IMO.
Norman Yuan
AutoCAD Map does provide command to convert map objects (FDO features) into native AutoCAD entities. However, it is unfortunate/shame that the Map platform APIs (now called Map geospatial APIs) does not provide API to do it. It is up to you, the programmer to invent your "own wheel": reading the MgGeometry's geometric data and generate corresponding native AutoCAD entities (polyline, arc, circle, point...), among them, generating polyline would be quite difficult code work on your own.
AutoCAD Map's Industrial Model APIs (IM APIs) include converting Feature geometrie to AutoCAD entities. But the Features in IM is different from Map Features, but at least you can learn from the sample code coming from IM.
With that said, since your goal is to bring data from *.shp file into AutoCAD as native AutoCAD entities (and the attribute data with these objects), you can do it much easier with AutoCAD MAP Import/Export APIs than using Platform API, where you need to convert the geometries with your own code. The AutoCAD Map Import/Export APIs do the same thing as you use command "MapImport" to import from SHP file.
So, if your goal is to learn and use Plafform APIs, go ahead with that. But if the goal is to bring data in SHP into AutoCAD, doing it with Map's Import/Export API would be easier and more pragmatic, IMO.
Norman Yuan
Yaun,
Maybe I should have clarified as to the go I'm trying to achieve. I have about 70* shape files connected through the built in ACAD "Map Connect. Utilizing "MAPIMPORT" brings in the ACAD objects, but non program accessible data
I'm successfully extracted all of the property names and values using a "type" conational statement to print to the command line for reference later in my code.
Th geometry property is the one I'm not able to access, as it seems to be a collection of sorts. I.E.:
Layer: Property Value
7OF_OWNER_PubData_Parcels_Lay-OBJECTID-137937
9OF_OWNER_PubData_Parcels_Lay-PIN-0130300049
5OF_OWNER_PubData_Parcels_Lay-ACREAGE-92.9
9OF_OWNER_PubData_Parcels_Lay-ACRE_SOURC-Calculated
9OF_OWNER_PubData_Parcels_Lay-PARCEL_STA-Approved
5OF_OWNER_PubData_Parcels_Lay-TXT_ANGLE-0
5OF_OWNER_PubData_Parcels_Lay-SHAPE_Leng-0
7OF_OWNER_PubData_Parcels_Lay-ID-0
9OF_OWNER_PubData_Parcels_Lay-Field1-Null
9OF_OWNER_PubData_Parcels_Lay-Field2-Null
9OF_OWNER_PubData_Parcels_Lay-Field3-Null
9OF_OWNER_PubData_Parcels_Lay-Field4-Null
9OF_OWNER_PubData_Parcels_Lay-Field5-Null
9OF_OWNER_PubData_Parcels_Lay-Field6-Null
9OF_OWNER_PubData_Parcels_Lay-Field7-Null
9OF_OWNER_PubData_Parcels_Lay-Field10-Null
9OF_OWNER_PubData_Parcels_Lay-Field8-Null
5OF_OWNER_PubData_Parcels_Lay-Shape_STAr-679565.625
5OF_OWNER_PubData_Parcels_Lay-Shape_STLe-4492.44725671
13OF_OWNER_PubData_Parcels_Lay-Geometry-OSGeo.MapGuide.MgByteReader
Thanks in advance!
Michael Luckett
Yaun,
Maybe I should have clarified as to the go I'm trying to achieve. I have about 70* shape files connected through the built in ACAD "Map Connect. Utilizing "MAPIMPORT" brings in the ACAD objects, but non program accessible data
I'm successfully extracted all of the property names and values using a "type" conational statement to print to the command line for reference later in my code.
Th geometry property is the one I'm not able to access, as it seems to be a collection of sorts. I.E.:
Layer: Property Value
7OF_OWNER_PubData_Parcels_Lay-OBJECTID-137937
9OF_OWNER_PubData_Parcels_Lay-PIN-0130300049
5OF_OWNER_PubData_Parcels_Lay-ACREAGE-92.9
9OF_OWNER_PubData_Parcels_Lay-ACRE_SOURC-Calculated
9OF_OWNER_PubData_Parcels_Lay-PARCEL_STA-Approved
5OF_OWNER_PubData_Parcels_Lay-TXT_ANGLE-0
5OF_OWNER_PubData_Parcels_Lay-SHAPE_Leng-0
7OF_OWNER_PubData_Parcels_Lay-ID-0
9OF_OWNER_PubData_Parcels_Lay-Field1-Null
9OF_OWNER_PubData_Parcels_Lay-Field2-Null
9OF_OWNER_PubData_Parcels_Lay-Field3-Null
9OF_OWNER_PubData_Parcels_Lay-Field4-Null
9OF_OWNER_PubData_Parcels_Lay-Field5-Null
9OF_OWNER_PubData_Parcels_Lay-Field6-Null
9OF_OWNER_PubData_Parcels_Lay-Field7-Null
9OF_OWNER_PubData_Parcels_Lay-Field10-Null
9OF_OWNER_PubData_Parcels_Lay-Field8-Null
5OF_OWNER_PubData_Parcels_Lay-Shape_STAr-679565.625
5OF_OWNER_PubData_Parcels_Lay-Shape_STLe-4492.44725671
13OF_OWNER_PubData_Parcels_Lay-Geometry-OSGeo.MapGuide.MgByteReader
Thanks in advance!
Michael Luckett
MapImport DOES bring all the attribute into drawing with AutoCAD native objects in the form of ObjectData, which AutoCAD Map provides API to access.
Just being curious: if you bring the SHP data via Platform API as native AutoCAD entities, how/where the attribute data go (and somehow still related to the AutoCAD entities)? You probably either lose it, or write code to attach to the AutoCAD entities as XData, ExtensionDictionary, or ObjectData/Object Classification data, or datalink to external database? Again, if your goal is to bring SHP data into AutoCAD as AutoCAD entities with the attribute data still available to each entity, MapImport would be easier API to use.
Anyway, if you go with Platform API, you have almost been there. This old discussion would give you enough hint to go on next step:
HTH
Norman Yuan
MapImport DOES bring all the attribute into drawing with AutoCAD native objects in the form of ObjectData, which AutoCAD Map provides API to access.
Just being curious: if you bring the SHP data via Platform API as native AutoCAD entities, how/where the attribute data go (and somehow still related to the AutoCAD entities)? You probably either lose it, or write code to attach to the AutoCAD entities as XData, ExtensionDictionary, or ObjectData/Object Classification data, or datalink to external database? Again, if your goal is to bring SHP data into AutoCAD as AutoCAD entities with the attribute data still available to each entity, MapImport would be easier API to use.
Anyway, if you go with Platform API, you have almost been there. This old discussion would give you enough hint to go on next step:
HTH
Norman Yuan
My apologizes, maybe I'm just not catching on, or you know something I don't.
Agreed. Mapimport does indeed bring Feature Data Objects in as ACAD native objects with data included under a different alias that I can't seem to access. "OD:OF_Owner_PubData_Parcels_" versus the FDO data column "Feature Properties". Both have the same information, yet the FDO geometry is stored in the post ceding column under "Geometry", and the other is stored in the entities themselves. It seems to be a collection of data, as I can increment each vertex through a button in the properties panel.
I've not stumbled upon a way to access the "OD:*" portion of the Mapimport method, which is why I resorted to utilize the FDO data. Again, I'm just a developer seeking answers. 🙂
The geometry property type presents itself as a BLOB (OSGeo.MapGuide.MgByteReader-13), 13 being the property type by integer. It would seem that the-
ElseIf Property_Type = MgPropertyType.Geometry AndAlso isNull = False Then
Field_Value = Feature_Reader.GetGeometry(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag, Property_Type)
- would catch this condition, but with no avail. I'm not very familiar with how to handle the BLOB property type, nor to make it useable data. I appreciate the link regarding the geometry property type, but I doubt I can convert the BLOB property type with my current knowledge.
I would attach the *.DWG file, but I would have to also include the 70+ *.SHP files and I belive there is a size cap.
Thanks in advance,
Michael Luckett
My apologizes, maybe I'm just not catching on, or you know something I don't.
Agreed. Mapimport does indeed bring Feature Data Objects in as ACAD native objects with data included under a different alias that I can't seem to access. "OD:OF_Owner_PubData_Parcels_" versus the FDO data column "Feature Properties". Both have the same information, yet the FDO geometry is stored in the post ceding column under "Geometry", and the other is stored in the entities themselves. It seems to be a collection of data, as I can increment each vertex through a button in the properties panel.
I've not stumbled upon a way to access the "OD:*" portion of the Mapimport method, which is why I resorted to utilize the FDO data. Again, I'm just a developer seeking answers. 🙂
The geometry property type presents itself as a BLOB (OSGeo.MapGuide.MgByteReader-13), 13 being the property type by integer. It would seem that the-
ElseIf Property_Type = MgPropertyType.Geometry AndAlso isNull = False Then
Field_Value = Feature_Reader.GetGeometry(Tag)
Test_Property_Values(Field_Value.ToString, Obj_Layer, Tag, Property_Type)
- would catch this condition, but with no avail. I'm not very familiar with how to handle the BLOB property type, nor to make it useable data. I appreciate the link regarding the geometry property type, but I doubt I can convert the BLOB property type with my current knowledge.
I would attach the *.DWG file, but I would have to also include the 70+ *.SHP files and I belive there is a size cap.
Thanks in advance,
Michael Luckett
I am not saying which is better between Map platform APIs and Map APIs (which contained in "ManagedMapApi.dll", including namespace Autodesk.Gis.Map.ImportExport/ObjectData) for one to use without specific goal of work. In your case, since it seems you want to all geometries in SHP file to be brought into AutoCAD Map as NATIVE AutoCAD entities, thus I think using Map import/export API to do it would be much easier than using platform API, because with latter, you need write your OWN CODE to use geometric information obtained from platform API (but you have not even reached this step yet at this moment) to generate AutoCAD native entities.
So, if you do not mind to write your own code to generate AutoCAD native entities (invent a better or worse "new wheel"), you just need to reach the first step: obtain the geometry (MgGeometry) from FDO feature first. If you read the discussion provided with the link in my previous reply, you should have some code (borrowed from that discussion) like:
if ([propertyType] == ...)
{
//You get access to paticular feature property
}
...
//But when the property is Geometry type
//You need to obtain a MgGeometry object in order to access its geometric data
else if ([propertyType] == MgPropertyType.Geometry)
{
// This would read the binary geometry info from the feature
MgByteReader byteReader = reader.GetGeometry(propertyName);
OSGeo.MapGuide.MgAgfReaderWriter agfReader = new OSGeo.MapGuide.MgAgfReaderWriter();
//Then you obtain the MgGeometry object
OSGeo.MapGuide.MgGeometry geometry = agfReader.Read(byteReader);
//Now that you have the MgGeometry, you need to write code to generate the native AutoCAD entity
Autodesk.AutoCAD.DatabaseServices.ObjectId entId = ObjectId.Null;
switch (geometry.GeometryType)
{
case OSGeo.MapGuide.MgGeometryType.LineString:
entId = CreatePolyline(geometry); //Up to you to use the geometry information to create AutoCAD polyline
break;
case...
break;
}
}
I think, at this point, you question is answered, if you keep the Platform API approach. However, after you create all the AutoCAD native entities in the drawing, what about the attribute data comes with SHP/FDO source? How do you "link the data with the newly created AutoCAD entities? If you do not need the data any more, then that is fine. If you do, you need do extra work.
That is why using Map Importing API is much more easier> the geometries become native AutoCAD, and the attribute data attached to them as ObjectData, which can be accessed/manipulated via Map's ObjectData API. With Map API, you can import as many SHP file as you want. There is no need to create DrawingSet/Alias, as long as you know where the SHP files are. When you use Map API to import SHP data, you get chance to decide whether you want to import attribute data as ObjectData (all attributes, or only selected ones), or not; you can also choose desired OD table name, column name. It also automatically transform the coordinate system(projection), if the coordinate system of the SHP is different from the drawing's.
Again, what I have said aims your specific task: converting FDO geometries to native AutoCAD entities.
Norman Yuan
I am not saying which is better between Map platform APIs and Map APIs (which contained in "ManagedMapApi.dll", including namespace Autodesk.Gis.Map.ImportExport/ObjectData) for one to use without specific goal of work. In your case, since it seems you want to all geometries in SHP file to be brought into AutoCAD Map as NATIVE AutoCAD entities, thus I think using Map import/export API to do it would be much easier than using platform API, because with latter, you need write your OWN CODE to use geometric information obtained from platform API (but you have not even reached this step yet at this moment) to generate AutoCAD native entities.
So, if you do not mind to write your own code to generate AutoCAD native entities (invent a better or worse "new wheel"), you just need to reach the first step: obtain the geometry (MgGeometry) from FDO feature first. If you read the discussion provided with the link in my previous reply, you should have some code (borrowed from that discussion) like:
if ([propertyType] == ...)
{
//You get access to paticular feature property
}
...
//But when the property is Geometry type
//You need to obtain a MgGeometry object in order to access its geometric data
else if ([propertyType] == MgPropertyType.Geometry)
{
// This would read the binary geometry info from the feature
MgByteReader byteReader = reader.GetGeometry(propertyName);
OSGeo.MapGuide.MgAgfReaderWriter agfReader = new OSGeo.MapGuide.MgAgfReaderWriter();
//Then you obtain the MgGeometry object
OSGeo.MapGuide.MgGeometry geometry = agfReader.Read(byteReader);
//Now that you have the MgGeometry, you need to write code to generate the native AutoCAD entity
Autodesk.AutoCAD.DatabaseServices.ObjectId entId = ObjectId.Null;
switch (geometry.GeometryType)
{
case OSGeo.MapGuide.MgGeometryType.LineString:
entId = CreatePolyline(geometry); //Up to you to use the geometry information to create AutoCAD polyline
break;
case...
break;
}
}
I think, at this point, you question is answered, if you keep the Platform API approach. However, after you create all the AutoCAD native entities in the drawing, what about the attribute data comes with SHP/FDO source? How do you "link the data with the newly created AutoCAD entities? If you do not need the data any more, then that is fine. If you do, you need do extra work.
That is why using Map Importing API is much more easier> the geometries become native AutoCAD, and the attribute data attached to them as ObjectData, which can be accessed/manipulated via Map's ObjectData API. With Map API, you can import as many SHP file as you want. There is no need to create DrawingSet/Alias, as long as you know where the SHP files are. When you use Map API to import SHP data, you get chance to decide whether you want to import attribute data as ObjectData (all attributes, or only selected ones), or not; you can also choose desired OD table name, column name. It also automatically transform the coordinate system(projection), if the coordinate system of the SHP is different from the drawing's.
Again, what I have said aims your specific task: converting FDO geometries to native AutoCAD entities.
Norman Yuan
Thanks you for your prompt response. I was mistaken by indicating that the integer 13 was related to a BLOB property type rather than Geometry. I'm a standard AutoLISP/VisualLISP developer that is stemming to the VB.Net realm, if you will. I'm still very wet around the ears when it comes to these API's. The Platform API was the first one I stumbled upon, when I started this adventure.
To be completely transparent, I work with a stubborn group of GIS analysts that are set in there ways. The fields change without warning, so I'm having to dynamically update these fields for my Drafters in order to provide them with information that the require. Attributed blocks, with the correct amount of attributes using "mapimport", was my first thought, but doesn't solve the dynamic update. Maybe this is a discussion for a new thread...
If you have any thoughts on the matter, they would be greatly appreciated. I do need to retain the data, somehow, but all I have is a work around at the moment.
Thanks in advance!
Michael Luckett
Thanks you for your prompt response. I was mistaken by indicating that the integer 13 was related to a BLOB property type rather than Geometry. I'm a standard AutoLISP/VisualLISP developer that is stemming to the VB.Net realm, if you will. I'm still very wet around the ears when it comes to these API's. The Platform API was the first one I stumbled upon, when I started this adventure.
To be completely transparent, I work with a stubborn group of GIS analysts that are set in there ways. The fields change without warning, so I'm having to dynamically update these fields for my Drafters in order to provide them with information that the require. Attributed blocks, with the correct amount of attributes using "mapimport", was my first thought, but doesn't solve the dynamic update. Maybe this is a discussion for a new thread...
If you have any thoughts on the matter, they would be greatly appreciated. I do need to retain the data, somehow, but all I have is a work around at the moment.
Thanks in advance!
Michael Luckett
Can't find what you're looking for? Ask the community or share your knowledge.