I use microstation 08.11.09.578, DGN 2D V7 Upgrade V8
I use C# language
I want to break the LineString association into separate LineStrings as shown below
ElementScanCriteria _MSesc = new ElementScanCriteriaClass(); _MSesc.ExcludeAllTypes(); _MSesc.IncludeType(MsdElementType.LineString); ElementEnumerator oEnumeration = app.ActiveModelReference.Scan(_MSesc); while (oEnumeration.MoveNext()) { oEnumeration.Current.AsLineElement().AsDroppableElement().Drop(); }
I tried but it gives error "Specified cast is not valid"
ba ranh said:I use microstation 08.11.09.578, DGN 2D V7 Upgrade V8
What do you mean by 'DGN 2D V7 Upgrade V8'?
MicroStation's native file format is a DGN file. A file contains DGN models. A model can be 2D or 3D. A DGN file is neither 2D nor 3D.
A previous version of MicroStation used a different file format that is referred to as V7. See the History of MicroStation.
Upgrade V8 is meaningless.
ba ranh said:I use C# language
When you write C# code for MicroStation V8i then you are calling the VBA COM interface. Prefer to develop your prototype using just VBA.
That way you...
ba ranh said:I want to break the LineString association into separate LineStrings
A VBA LineElement implements the VertexList interface. Get that list and create a new LineElement for each pair of vertices in that list.
LineElement
VertexList
Regards, Jon Summers LA Solutions
Jon Summers said:A VBA LineElement implements the VertexList interface. Get that list and create a new LineElement for each pair of vertices in that list.
Good idea, thanks
Hi,
ba ranh said:I want to break the LineString association
It's not clear what you mean by "LineString association". The term "association" has exact meaning in MicroStation and API: Elements, like dimensions for example, can be associative to another elements. It does not make sense to use it in the discussed context.
ba ranh said:I want to break the LineString association into separate LineStrings as shown below
There are several issues in your code. I am not sure they are a result of not understanding how COM API works or you did not read API documentation carefully:
Another issue, but it's subjective one, is "an ugliness": You mixed old VB style (using names like oEnumeration does not make any sense today and is treated as bad practice generally) with C style (using _ for, probably, instance or local variables). When C# was released, naming best practices were defined by Microsoft, so when you decided to use C#, you also should follow the "C# code and naming style".
ba ranh said:into separate LineStrings
The solution recommended by Jon is the simplest and elegant one.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thank you for your useful sharing
ba ranh said:Good idea
Here's some sample code.