I resume this old discussion of 2016 and I ask .... in the event that we find a complex form (MSDelementtyPecomplexshape) how the function should be changed to be able to elevate a shape that contains two arches and two lines.
Option Explicit Sub TestMoveShape() Dim elemId As DLong elemId = DLongFromLong(1307192) Dim el As Element Set el = ActiveModelReference.GetElementByID(elemId) If (msdElementTypeShape = el.Type) Then processShape el.AsShapeElement End If End Sub Private Sub processShape(shape As ShapeElement) Dim numOfVertices As Long numOfVertices = shape.VerticesCount Dim index As Long For index = 1 To numOfVertices shape.vertex(index) = moveVertex(shape.vertex(index)) Next shape.Rewrite End Sub Private Function moveVertex(vertex As Point3d) As Point3d Const zVal = 53.65 moveVertex = vertex moveVertex.Z = zVal End Function
Tiziano Sapora said:how the function should be changed to be able to elevate a shape that contains two arches and two lines.
It’s not clear what you are trying to accomplish, can you share screenshots showing the before and after?
I simply would like to adapt the previously attached code to make sure that given a complex shape consisting of two lines and two arches that enclose a text, it can be made so that everything can be translated compared to the Z to a value specified by the user. The attached code already does it but with a "msdelemendypeshape" type form Thank you.
correct "AsShapeElement"
Tiziano Sapora said:I simply would like to adapt the previously attached code to make sure that given a complex shape consisting of two lines and two arches that enclose a text, it can be made so that everything can be translated compared to the Z to a value
Move away from individual DGN elements and look at a bigger picture.
All graphic elements have a Transform method. That method takes a Transform3d matrix. Construct a Transform3d using the many methods available. See MicroStation VBA help for examples.
Transform
Transform3d
Regards, Jon Summers LA Solutions
Hi Tiziano,
in my opinion you choose wrong approach:
I do not know a context of original discussion and code, but as Jon wrote, it is wrong to move vertices individually, when an element offers Transform method.
Also, another wrong assumption is that code used for simple shape can be easily transformed to be used with complex shape. Sometimes yes, but often not. The shape is simple element, whereas ComplexShape is complex element, consisting from more different elements internally. It means to access the content works in a different way.
And it is situation where Transform method makes sense, because it allows to manipulate with the whole element in a uniform way, regardless its type.
Or you are interested in some internal modifications, so not to simple move the whole element in Z axis direction?
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Tiziano Sapora said:it can be made so that everything can be translated compared to the Z to a value specified by the user
Here's an example you will find in VBA help...
' Flatten geometry to the plane z = 3 Set oFlatElement = oElement.Clone oFlatElement.transform Transform3dFromMatrix3dPoint3d(Matrix3dFromScaleFactors(1, 1, 0), Point3dFromXYZ(0, 0, 3))
It's in topic Flattening Elements: Demonstrates how to flatten geometry to any plane, specifically including constant-z planes (e.g. "SetZ") .
Tiziano Sapora said:From what I seemed to understand with "transform3d"
Transforms are not specific to MicroStation VBA: they are a widely-used mathematical concept. Matrix3d and Transform3d are MicroStation VBA representations of common objects. Take a look at this page and follow links to other sites.
Matrix3d
Hey Jon, first of all, thank you for your advices, I've found them super useful.Taking Tiziano's problem a bit further, I think we have 2 distinct situations, when trying to translate a ComplexChain or ComplexShape along the Z axis:
1) flattening the element in the process - that is the easy part. The following code will do the job (will flatten the element and elevate it to 10m) : ele.Transform Transform3dFromMatrix3dPoint3d(Matrix3dFromScaleFactors(1, 1, 0), Point3dFromXYZ(0, 0, 10))2) non-flattening transform. In theory, the following code should do : ele.Transform Transform3dFromMatrix3dPoint3d(Matrix3dFromScaleFactors(1, 1, 1), Point3dFromXYZ(0, 0, 10))However, instead of translating it to the specified elevation (10, in this case), it will simply add 10 to the existing elevation.What am I missing ?Best regards,Paul
Paul Mitache said:Transform3dFromMatrix3dPoint3d(...)However, instead of translating it to the specified elevation (10, in this case), it will simply add 10 to the existing elevation
From VBA help: Returns a transformation from given matrix and translation parts. So, yes, in your example it does what is expected.
There are a lot of methods that work with Transform3d: search for Transform3d Type in VBA help. Perhaps Transform3dFromMatrix3dAndFixedPoint3d will do what you want?
Transform3dFromMatrix3dAndFixedPoint3d