Dear all,
Am new one to this forum and microstation VBA development. As mentioned in the above subject facing an unknown error while splitting the one shape element into two shapes, Where it is crossed by line element.
below attached code working fine with microstation v8i version but throwing unkown error in v8. Kindly help to fix the error in the below attached code and dgn file.
Public Function CreateRegion()Dim ee As ElementEnumeratorDim sh As ElementDim lne As ElementDim eles() As Element
'Intersection line elementSet lne = ActiveModelReference.GetElementByID(DLongFromLong(1822973))'Shape elementSet sh = ActiveModelReference.GetElementByID(DLongFromLong(1822965))ReDim Preserve eles(0)Set eles(0) = lneReDim Preserve eles(1)Set eles(1) = shSet ee = lne.AsShapeElement.GetIntersectionShapesFromRegion(eles, Nothing, msdFillModeNotFilled)While ee.MoveNext Dim ele As Element Set ele = ee.Current ActiveModelReference.AddElement eleWendEnd Function
1234.GetIntersectionFromRegion.dgn
Dasharath VB said:Where it is crossed by line element.
Can you do it, in one operation, manually, using MicroStation tool? I do not recall such tool and all workflows I know require more steps. Can you provide more details how the expected result was created? It can help to analyze how to simulate the same functionality using API.
Dasharath VB said:As mentioned in the above subject facing an unknown error while splitting the one shape element into two shapes
I am not sure whether the used method accepts open elements.
I recommend to check Boolean Operations on Closed Elements and Planar Regions chapter in MicroStation VBA help. There is extensive sample explaining how different methods should be used (by it does not work when run in MicroStation CE).
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Dear Jan,
Thanks for your response.
Jan Ĺ legr said:Can you provide more details how the expected result was created?
The expected output was created by using the below code in microstation v8i SS3. But this code is not working in Microstation v8 2004 Edition.
Public sub CreateRegion() Dim ee As ElementEnumerator Dim sh As Element Dim lne As Element Dim eles() As Element 'Intersection line element Set lne = ActiveModelReference.GetElementByID(DLongFromLong(1822973)) 'Shape element Set sh = ActiveModelReference.GetElementByID(DLongFromLong(1822965)) ReDim Preserve eles(0) Set eles(0) = lne ReDim Preserve eles(1) Set eles(1) = sh Set ee = lne.AsShapeElement.GetIntersectionShapesFromRegion(eles, Nothing, msdFillModeNotFilled) While ee.MoveNext Dim ele As Element Set ele = ee.Current ActiveModelReference.AddElement ele Wend End sub
Dasharath VB
Hi,
thanks for the details, the information about versions is important.
Dasharath VB said:The expected output was created by using the below code in microstation v8i SS3. But this code is not working in Microstation v8 2004 Edition.
So does it mean that code work in old V8i (SELECTseries 3), but does not work in much older V8 2004 Edition?
Because V8 2004 Edition was released 17 years ago, I do not think anybody is able to analyze why it does not work. Maybe it's because bug in VBA API, but it can also be caused by problem in MicroStation engine itself ... a lot of things in MicroStation changed between 2004 Edition and SELECTseries 3.
If you really need to use such old version, I think the only solution is to call MDL function(s) from VBA. But until tested, it's not clear whether the problem is (not) in the engine itself, se also MDL function does not work right.
With regards,
Just in addition to Jan,
there was a big crack in the line of the APIs / SDKs in that time, I remember we hat two Independent branches of our source code, because the differences were to big for one solution.
Mit freundlichen Grüßen / Best regards Volker Hüfner
| AB_DATE Engineering Software | ab-date.de |
Hi Jan,
thanks for your response.
Hi Volker,
Thanks for the response.
Dasharath VB said:The expected output was created by using the below codeSet ee = lne.AsShapeElement
Set ee = lne.AsShapeElement
You obtain a line element by its ID and assign it to an Element variable. Then you cast that to a ShapeElement and call a method of the ClosedElement interface.
Element
ShapeElement
ClosedElement
I don't see how that would work in any version of MicroStation.
Regards, Jon Summers LA Solutions
Thanks Jon,
I will try with your logic.
Dasharath VB said: I will try with your logic
I wasn't suggesting anything. I analysed and commented on your code.
But, if you want a suggestion, try this...
LineElement
ShapeElement.GetIntersectionShapesFromRegion()
Hi Jon,
Thanks for your response, By creating the zero-width shapeElement, ElementEnumerator returing null element.
Public sub CreateRegion() Dim ee As ElementEnumerator Dim sh As Element Dim lne As Element Dim lne2 As ShapeElement Dim eles() As Element 'line element Set lne = ActiveModelReference.GetElementByID(DLongFromLong(1822969)) If (lne.IsLineElement) Then Dim Verts() As Point3d Verts = lne.AsLineElement.GetVertices() ReDim Preserve Verts(UBound(Verts) + 1) Verts(UBound(Verts)) = Verts(0) Set lne2 = CreateShapeElement1(Nothing, Verts, msdFillModeNotFilled) ActiveModelReference.AddElement lne2 lne2.Redraw msdDrawingModeNormal End If ' Shape Element Set sh = ActiveModelReference.GetElementByID(DLongFromLong(1822912)) ReDim Preserve eles(0) Set eles(0) = lne ReDim Preserve eles(1) Set eles(1) = sh Set ee = lne2.AsShapeElement.GetDifferenceShapesFromRegion(eles, Nothing, msdFillModeNotFilled) While ee.MoveNext Dim ele As Element Set ele = ee.Current ActiveModelReference.AddElement ele Wend End sub
Regards
Answer Verified By: Dasharath VB
By creating the Zero-Width shapeElement from LineElement coordiantes, ElementEnumerator returns null value.
Public Function CreateRegion() Dim ee As ElementEnumerator Dim sh As Element Dim lne As Element Dim lne2 As ShapeElement Dim eles() As Element 'line element Set lne = ActiveModelReference.GetElementByID(DLongFromLong(1822969)) If (lne.IsLineElement) Then Dim Verts() As Point3d Verts = lne.AsLineElement.GetVertices() ReDim Preserve Verts(UBound(Verts) + 1) Verts(UBound(Verts)) = Verts(0) Set lne2 = CreateShapeElement1(Nothing, Verts, msdFillModeNotFilled) ActiveModelReference.AddElement lne2 lne2.Redraw msdDrawingModeNormal End If ' Shape Element Set sh = ActiveModelReference.GetElementByID(DLongFromLong(1822912)) ReDim Preserve eles(0) Set eles(0) = lne2 ReDim Preserve eles(1) Set eles(1) = sh Set ee = lne2.AsShapeElement.GetDifferenceShapesFromRegion(eles, Nothing, msdFillModeNotFilled) While ee.MoveNext Dim ele As Element Set ele = ee.Current ActiveModelReference.AddElement ele Wend End Function
Dasharath VB said:By creating the Zero-Width shapeElement from LineElement coordiantes, ElementEnumerator returns null value
Well, it was just a suggestion.
Are you familiar with MicroStation's Partial Delete tool (key-in DELETE PARTIAL)? Try it in MicroStation. If it does what you want you can use VBA's PartialDelete method.
DELETE PARTIAL
PartialDelete