I'm testing Extrude to solid method as follows:
Sub TestExtrude() Dim oEle As Element 'Dim oSmartSolid As SmartSolid Dim oSmartSolidEle As SmartSolidElement Set oEle = ActiveModelReference.GetElementByID(DLongFromString("62494")) 'This is not necessary as Jan pointed out below 'Set oSmartSolid = SmartSolid If oEle.IsPlanarElement Then ' Set oSmartSolidEle = oSmartSolid.ExtrudeClosedPlanarCurve(oEle, 100, 0, True) Set oSmartSolidEle = SmartSolid.ExtrudeClosedPlanarCurve(oEle, 100, 0, True) End If ActiveModelReference.AddElement oSmartSolidEle oSmartSolidEle.Redraw End Sub
The problems are
1. what I got is different from what I manually extruded by using command "Solid by Extrusion". See pic below, the left one is what I extruded manually, the right one is by code. the manual one is solid, the code one is smartsolid; the manual one is just one element, the code one is two elements, the original profile and the extruded smartsolid;
2. The method syntax is
Syntax
Set SmartSolidElement = object.ExtrudeClosedPlanarCurve (planarClosedElement, forwardDist, backwardDist [, capSurface])
But even I changed the forwardDis or/backwardDis, but there is no difference with extrusion direction, in this case, always downward.
Questions:
1. How can I make the code one as the same as the manual one?
2. How to control the extrude direction?
Any replies appreciated. Thanks.
Hi Wence,
few comments:
Unknown said:1. How can I make the code one as the same as the manual one?
Often there is no direct reference between user tools and methods available in API in terms of their behaviour. In my opinion there are two separate issues there:
Unknown said:2. How to control the extrude direction?
Frankly, I am also not sure how forwardDist and backwardDist should work, but working solution is to use forwardDist only with positive values, which means identical with a profile normal direction, and negative values, which extrudes the profile in an oposite direction.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Unknown said:I've reinserted the code using Syntaxhighlighter.
Great, it looks much better now! ;-)
Unknown said:Solid vs. SmartSolid: the problem is they display differently even in the same display style
I have not dived into the differences between solids and smart solids, but because they are different element types represented in a different way internally, I assume they can be also displayed differently. But I don't think this is the case ...
Unknown said:as you can see in my pic, the one by code looks transparent
... because I tested it with my MicroStation V8i (SELECTseries 3) Update 2 and both manually created solid and smart solid created by VBA code are displayed in the same way. So the problem is probably somewhere else, not the objects are different types.
Unknown said: And as you said, it seems no method to convert smartsolid to solid.
Fortunately it will be solved in MicroStation CONNECT Edition, because a new internal representation of 3D objects is used and the "solid vs smart solid schizofrenia" will be the past.
Thanks again Jan. My SS3 is 08.11.09.536.
I tested again, extrude a circle, but same result.
How this file is displayed? And what display style do you use?
work3d.dgn
Regards,
both smartsolid and solid in your file look the same. So I attached my file, but no matter which display style I used, smooth or illustration, my smartsolid by vba still looks not good, very strange...
Seed3dm.dgn
You should start your macro with
SetCExpressionValue "tcb->smartGeomSettings.flags.representAsSurfaces", 1, "3DTOOLS"
to be sure the setting has the correct value (surface).
Unknown said: You should start your macro with ? 1 SetCExpressionValue "tcb->smartGeomSettings.flags.representAsSurfaces", 1, "3DTOOLS" to be sure the setting has the correct value (surface). Regards, Jan
SetCExpressionValue
"tcb->smartGeomSettings.flags.representAsSurfaces"
, 1,
"3DTOOLS"
Thank you soooo much Jan, you're amazing! I would never have thought about that setting will affect the extrusion later..thanks again.
Answer Verified By: Wence
Unknown said:I would never have thought about that setting will affect the extrusion later..thanks again.
I also not ... learning every day :-)