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"
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