AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

get properties of MgGeometry

1 REPLY 1
Reply
Message 1 of 2
Anonymous
608 Views, 1 Reply

get properties of MgGeometry

Anonymous
Not applicable
     While reader.ReadNext()
                Dim geometry as MgGeometry = agfReader.Read(reader.GetGeometry(myLayer.FeatureGeometryName))
               Dim propcol As MgPropertyCollection = new MgPropertyCollection()

                Select Case geometry.GeometryType
Case MgGeometryType.MultiPolygon i = 0 tempString = Nothing collOfCoord.Clear() Dim multiPolygon As MgMultiPolygon = TryCast(geometry, MgMultiPolygon) Dim coordIterator as MgCoordinateIterator = multiPolygon.GetCoordinates() While coordIterator.MoveNext() Dim multiPolyCoord As MgCoordinate = coordIterator.GetCurrent() CollOfCoord.Add(MultiPolyCoord) End While

I have code to recognize which type of geometry preseneted on map. For every geometry on this map exists ID, LAYER_ID and so on... I'd like to know is there any way to get these properties(ID, LAYER_ID...) for current geometry?Screenshot_1.png

0 Likes

get properties of MgGeometry

     While reader.ReadNext()
                Dim geometry as MgGeometry = agfReader.Read(reader.GetGeometry(myLayer.FeatureGeometryName))
               Dim propcol As MgPropertyCollection = new MgPropertyCollection()

                Select Case geometry.GeometryType
Case MgGeometryType.MultiPolygon i = 0 tempString = Nothing collOfCoord.Clear() Dim multiPolygon As MgMultiPolygon = TryCast(geometry, MgMultiPolygon) Dim coordIterator as MgCoordinateIterator = multiPolygon.GetCoordinates() While coordIterator.MoveNext() Dim multiPolyCoord As MgCoordinate = coordIterator.GetCurrent() CollOfCoord.Add(MultiPolyCoord) End While

I have code to recognize which type of geometry preseneted on map. For every geometry on this map exists ID, LAYER_ID and so on... I'd like to know is there any way to get these properties(ID, LAYER_ID...) for current geometry?Screenshot_1.png

1 REPLY 1
Message 2 of 2
tamara
in reply to: Anonymous

tamara
Advocate
Advocate

Hello, 

 

 here is an example of reading feature properties (sorry I write in C#, you can translate it to VB online):

//Get feature service
MgFeatureService featureService = AcMapServiceFactory.GetService(MgServiceType.FeatureService) as MgFeatureService;
//Get class definition for class name
MgClassDefinition clDef = featureService.GetClassDefinition(resource, schemaName, className); MgPropertyDefinitionCollection classPropeties = clDef.GetProperties();
MgFeatureReader reader = featureService.SelectFeatures(resource, className, query);
while(reader.ReadNext())
{
foreach (var property in classPropeties)
{
string propertyName = property.Name;
//for data properties
if(property.GetPropertyType() == MgFeaturePropertyType.DataProperty)
{
var propDef = property as MgDataPropertyDefinition;
var propType = propDef.GetDataType();
switch (propType)
{
case (MgPropertyType.Int16):
Int16 prop16 = reader.GetInt16(propertyName);
break;
case (MgPropertyType.String):
Int32 prop32 = reader.GetInt32(propertyName);
break;
//etc.
}
}
//for geometry property
else if (property.GetPropertyType() == MgFeaturePropertyType.GeometricProperty)
{
var geomProp = property as MgGeometricPropertyDefinition;
var geomType = geomProp.GeometryTypes;
switch (geomType)
{
case (MgGeometryType.Polygon):
//your code
break;
//etc.
}
}
} }

 

Hope it hepls. 

0 Likes

Hello, 

 

 here is an example of reading feature properties (sorry I write in C#, you can translate it to VB online):

//Get feature service
MgFeatureService featureService = AcMapServiceFactory.GetService(MgServiceType.FeatureService) as MgFeatureService;
//Get class definition for class name
MgClassDefinition clDef = featureService.GetClassDefinition(resource, schemaName, className); MgPropertyDefinitionCollection classPropeties = clDef.GetProperties();
MgFeatureReader reader = featureService.SelectFeatures(resource, className, query);
while(reader.ReadNext())
{
foreach (var property in classPropeties)
{
string propertyName = property.Name;
//for data properties
if(property.GetPropertyType() == MgFeaturePropertyType.DataProperty)
{
var propDef = property as MgDataPropertyDefinition;
var propType = propDef.GetDataType();
switch (propType)
{
case (MgPropertyType.Int16):
Int16 prop16 = reader.GetInt16(propertyName);
break;
case (MgPropertyType.String):
Int32 prop32 = reader.GetInt32(propertyName);
break;
//etc.
}
}
//for geometry property
else if (property.GetPropertyType() == MgFeaturePropertyType.GeometricProperty)
{
var geomProp = property as MgGeometricPropertyDefinition;
var geomType = geomProp.GeometryTypes;
switch (geomType)
{
case (MgGeometryType.Polygon):
//your code
break;
//etc.
}
}
} }

 

Hope it hepls. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report