Let us suppose that I have 5 3D polygons in my DGN file. I wish to extract the coordinates of the vertices in the DGN file. My questions are as follows:
(a) Is it possible to assign tags / attributes either programmatically or through front end to each of the 3D polygons?
(b) Is it possible to query the polygons present in the DGN file based on the attributes?
(c) Is it possible to extract the coordinates of the vertices of each of the polygons.
Thanks in advance.I am asking this question because I cannot understand the documentation.
Unknown said:I am asking this question because I cannot understand the documentation
You have my sympathy. It's not always easy to make sense of formal documentation.
Let's be clear on terminology. A DGN file is a container. It contains one or more models. A model is a 2D or 3D drawing space where you create graphic elements.
In MicroStation, a polygon is represented by a shape element. You can create a shape element in 3D space, but the shape itself should be planar.
Unknown said:Let us suppose that I have 5 3D polygons in my DGN file
I interpret your statement like this: you have a DGN file that contains a 3D model. In that model are five shape elements. You want to extract the coordinates of those shapes.
Unknown said:Is it possible to query the polygons
The MicroStation idiom to query a model is the scanner. A ModelReference has a Scan method. You filter the results of a scan by setting the ScanCriteria class properties. The result of a scan is an ElementEnumerator object. Iterate the ElementEnumerator to see each element that passed the scan criteria.
This article discusses Scanning a Model using MicroStation VBA. There are also examples in VBA help.
Unknown said:Is it possible to extract the coordinates of the vertices of each of the polygons?
Yes. ShapeElement.GetVertices provides an array of Point3d data.
Regards, Jon Summers LA Solutions
Please let me know what is the problem here. I have done almost the same as what Jon Summers suggested.
Sub myDumVertices()Dim theListOfElements As ElementEnumeratorDim theElement As ShapeElementDim myVertexList() As Point3dDim myScanCriteria As ElementScanCriteria'create new scan criteriaSet myScanCriteria = New ElementScanCriteria'set scan criteria to remove annotationsmyScanCriteria.ExcludeNonGraphical'scan elements and set to element enumeratorSet theListOfElements = ActiveModelReference.Scan(myScanCriteria)'iterate over each of the elements nowDo While theListOfElements.MoveNext 'catch the current element Set theElement = theListOfElements.Current 'catch the list of vertices Set myVertexList = theElement.GetVertices() 'process the list of points here myProcessList myVertexListLoopEnd Sub
The code cries, cannot assign to Array!!
Hi,
without testing your code, I see these problems:
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Jan,
If I use,
myVertexList = theElement.GetVertices()
VBA Cries with the following message:
"Class does not support Automation or does not support expected interface'
Therefore, I used your suggestion, and coded the following:
Sub myDumVertices()'create new scan criteriaDim myScanCriteria As ElementScanCriteriaSet myScanCriteria = New ElementScanCriteria'set scan criteria to remove annotationsmyScanCriteria.ExcludeNonGraphical'scan elements and set to element enumeratorDim theListOfElements As ElementEnumeratorSet theListOfElements = ActiveModelReference.Scan(myScanCriteria)'iterate over each of the elements nowDo While theListOfElements.MoveNext 'catch the current element Dim theElement As Element Set theElement = theListOfElements.Current If theElement.IsShapeElement Then 'catch the list of vertices Dim myVertexList() As Point3d myVertexList = theElement.AsShapeElement.GetVertices() 'process the list of points here myProcessList myVertexList End IfLoopEnd SubSub myProcessList(thePoints() As Point3d)Dim i As IntegerFor i = LBound(thePoints) To UBound(thePoints) Debug.Print "The vertex item " + CStr(i) + " is " + CStr(thePoints(i).X) + ", " + CStr(thePoints(i).Y) + ", " + CStr(thePoints(i).Z)Next iEnd Sub
This works!
Thanks for your help. Hope my programming looks better now!
Answer Verified By: Suddhasheel Ghosh