Unable to extrude NESTED PROFILES with AddFiniteExtrudedProtrusion()

Hello there, this should be easy, but it's driving me absolutely mad.


I need to extrude from the API a sketch which is previously drawn in the part file. Seems easy, isnt' it?


The purpose of this is checking that the sketch is correctly defined (it defines a solid shape) and making further volume checkings on the component in order to study it's manufacture material. That sketch is created previously in each part by the user.


The not-so-weird fact is that that sketch can contain "holes", but that shouldn't be a problem as far as the resulting geometry is valid for a solid extrusion.


My code works as far as the sketch does not contain holes,but fails to extrude as soon as I use nested profiles in the sketch definition in order to define "voids". However, if I try to extrude that sketch directly from the SE interface, selecting all the lines (including voids), the extruding works smoothly.


Using Solid Edge Spy, I see that original sketch contains a single profile for the whole shape+voids. However, as soon as I manually extrude all those lines, more profiles are generated, and it seems that SE separates exterior shape and voids in different profiles in order to define the whole extrusion. With all, I think that extruding profiles with holes is a bit more complex than it seems, but I can't get more info around.


My current code is this:


'Get all my objects: 
'oModels contains the Models collection
'oSketchToAnalyze contains the sketch which I need to extrude
'dExtrusionThickness contains the thickness for the extrusion

oModels.AddBody(SolidEdgePart.AddBodyTypeConstants.igPartType, "Sketch Shape Checking") 'Make the extrusion in a new model oModels.Item(oModels.Count).MakeActive()
oModels.AddFiniteExtrudedProtrusion(1, CType({oSketchToAnalyze.Profile}, Array), SolidEdgePart.FeaturePropertyConstants.igSymmetric, dExtrusionThickness)

'Recall the last created extrusion and check it
Dim oModel As SolidEdgePart.Model = oModels.Item(oModels.Count)
Dim oExtrusion As SolidEdgePart.ExtrudedProtrusion = oModel.ExtrudedProtrusions.Item(oModels.Item(oModels.Count).ExtrudedProtrusions.Count)
Dim bExtrusionValid As Boolean = (oExtrusion.Status = SolidEdgePart.FeatureStatusConstants.igFeatureOK) 'This yields False when the sketch's profile has nested profiles for voids!


 In fact, when the status is not OK, no model is added to the part.


How can I replicate from the API the fact of extruding all lines of a defined sketch, without worrying about nested profiles and so?


I tried the same using surfaces with the same result, all works fine until you use nested shapes in the sketch used for extruding, even when that sketch can be extruded from SE interface without any problem just selecting al single lines.


Since I'm dealing with sketches previously drawn by the user, I don't know how to differenciate between exterior contour and voids in order to make different operations or so, but I guess this shouldn't be mandatory.


Thanks for your attention, any help will be appreciated!




Re: Unable to extrude NESTED PROFILES with AddFiniteExtrudedProtrusion()

 I am not set up to try this but try oring with igInside.

SolidEdgePart.FeaturePropertyConstants.igSymmetric OR SolidEdgePart.FeaturePropertyConstants.igInside



Re: Unable to extrude NESTED PROFILES with AddFiniteExtrudedProtrusion()

I have tried that but it didn't work. In fact there's no detailed documentation about all the possibilities of the FeaturePropertyConstants enumeration. Since the numeroic values are not all powers of 2, I guess that they are not intended to be combined using the OR operator.

Yesterday I was further investigating this stuff, and seems that extruding nested profiles is far from being so straightforward.

The first thing I noticed is that, when you extrude in SE form an existing sketch, the profile is somewhat duplicated, and another profile is generated. That can easily be analyzed in Solidedge Spy with a simple example.

Suposse we make a sketch like the figure:




And then we extrude it, selecting all its lines, so we are not generating another sketch from SE.

In SPY we can inspect the original profile looking into Sketch.Profile. There we see the profile we drawn, with all its lines, relations, dimensions and so.



However, if we inspect the ExtrudedProtusion, we can see that another Profile is kept there. This Profile can also be found in the ProfileSets collection. I must say that in that collection, the sketch's profile doesn't appear, so it seems that it's intended to hold the profiles specifically used by modeling operators, but not isolated sketchs.



So, SE has generated a clone profile which, indeed, it's not exactly the same. As you can see in the image, this clone has no dimensions attached, and the number of relationships has changed. Analyzing the Type property of those relationships, I can see two things:

-Only the original igKeyPointRelation2d has been kept. There were other relationships igHorizontal/igVertical which are not cloned. Maybe this is done in order to be sure that the cloned profile is somewhat closed.
-A new relationship has been added. No clue about what type of relation is that: it's type id is 296913277, which does not match any of the possible values according documentation.

The most weird thing here is when we try to extrude that sketch from the API, calling:


Dim oPartDoc As SolidEdgePart.PartDocument = CType(CSolidEdge.LoadActiveDocument(), SolidEdgePart.PartDocument)
Dim oModels As SolidEdgePart.Models = oPartDoc.Models
Dim oSketch As SolidEdgePart.Sketch = oPartDoc.Sketches.Item(1)
Dim oProfile As SolidEdgePart.Profile = CType(oSketch.Profile, SolidEdgePart.Profile)
Dim oModel As SolidEdgePart.Model = oModels.AddFiniteExtrudedProtrusion(1, CType({oProfile}, Array), SolidEdgePart.FeaturePropertyConstants.igSymmetric, 10 / 1000)
Dim oExtrusion As SolidEdgePart.ExtrudedProtrusion = oModel.ExtrudedProtrusions.Item(1)
Dim bExtrusionValid As Boolean = (oExtrusion.Status = SolidEdgePart.FeatureStatusConstants.igFeatureOK)

In this case, we get the same extruded protusion, which is valid, but no new profile is generated, so the Profile property of both the ExtrudedProtusion and the Sketch is the same object. This could be cool, but as soon as we try the same with this skecth, the API fails when trying to extrude:




Again, if we manually extrude a nested profile, the results from Spy are quite different. Now, SE generates 2 new profiles, which can be located in the ProfileSets collection. One contains the circle and the other all the lines. The Profile object of the Extrudedprotusion operator is null. I guess we would need to call GetProfiles and we would get those 2 profiles generated.




If we add another hole in the sketch, 3 profiles are generated for the extrusion and so on...

With all, it's clear that when extruding from a sketch, SE generates as many profiles as needed to feed the extrusion, each one containing a closed area. However, if I need to extrude from the API an arbitrary sketch, how can I clone that sketch and divide it in as many profiles as closed areas are contained?


Can the API do this work automatically as it's done by SE? Identifying closed areas and separate them it's far from being an easy task...


Many thanks for your attention and time