Lines and Linestrings
Don't confuse element types with interface types. I spent some time today looking for IsLineStringElement. It had occurred to me that IsLineElement probably worked for both but it didn't occur to me that I could pass a line string as a LineElement and get valid results. Turns out it works.
So the function I was working with scans a design file for lines and linestrings and then makes sure that I have the correct element type but testing for IsLineElement. Line Strings pass this test too. And I can use AsLineElement for the element in either case. So you can do this,
Dim ipts() as point3d
ipts = element.AsLineElement.GetIntersectionPoints(oTestLine, Matrix3dIdentity)
Where test line is a line that might intersect my line or line string.
In the past I might have done something like,
If .Type = msdElementTypeLine Then
. . .
elseif .Type = msdElementTypeLineString Then
. . .
end if
But then what is the element type really? It's still a LineElement to vba eventhough MicroStation's element type = 3 and type = 4 for line and line string respectively.
In this case the interface takes care of the element type. I don't know how. That's something for someone smarter than me to answer. Bottom line is that Lines and LineStrings are handled by the same interface. So stick with the interface test IsLineElement and not the type test.



0 Comments:
Post a Comment
<< Home