[V8i MVBA] Extrude Profile to Solid

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.

Parents
  • Hi Wence,

    few comments:

    • It would be nice to reinsert your code using Syntaxhighlighter (yellow pencil icon), so it will be nicely formated and consequently easier to read.
    • There is no need to use Set oSmartSolid = SmartSolid, you can use SmartSolid directly, it's always existing object.

    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:

    • Orifinal profile left: The tool Solid by Extrusion contains Keep original switch, which deletes the original profile when the extrusion is finished. ExtrudeClosedPlanarCurve method does extrusion only, so it's up to you to delete the original element if you don't need it.
    • Solid vs. SmartSolid: Solid by Extrusion creates solid, ExtrudeClosedPlanarCurve creates SmartSolid. There is no Solid API available in MicroStation VBA, so you should find another way how to convert SmartSolid to Solid (I don't know, can it be done somehow in MicroStation?).

    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

Reply
  • Hi Wence,

    few comments:

    • It would be nice to reinsert your code using Syntaxhighlighter (yellow pencil icon), so it will be nicely formated and consequently easier to read.
    • There is no need to use Set oSmartSolid = SmartSolid, you can use SmartSolid directly, it's always existing object.

    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:

    • Orifinal profile left: The tool Solid by Extrusion contains Keep original switch, which deletes the original profile when the extrusion is finished. ExtrudeClosedPlanarCurve method does extrusion only, so it's up to you to delete the original element if you don't need it.
    • Solid vs. SmartSolid: Solid by Extrusion creates solid, ExtrudeClosedPlanarCurve creates SmartSolid. There is no Solid API available in MicroStation VBA, so you should find another way how to convert SmartSolid to Solid (I don't know, can it be done somehow in MicroStation?).

    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

Children