The title and body of your question do not seem to match. In the title, you're asking how to detect an extrusion that was converted to sheet metal (using Convert to Sheet Metal I suppose) and in the body of your post you want to detect whether a sheet metal part contains bends.
Please edit the title and/or body of your post to more clearly state your problem so we can help you better. Also, it would be helpful if you posted images indicating what feature you're trying to detect. You could also post a part and let us know what feature you're trying to detect.
For future reference, please see How to ask a good question in the API forum
Ok, in short words i am trying to write macro that will:
1. Select face of a part (Done)
2. Make normal to view (Done)
3. Make new drawing (Done)
4. Insert view from view pallet (view marked at "*current" in step 2) - Done
5. Marco should now decide:
5a.) Part contains extrusion only - insert view from step 2
5b.) Part contains extrusion converted to sheet metal (still plate only) - insert view from step 2
5c.) Part contains extrusion converted to sheet metal but bends are made by conversion - its not a plate, just some converted part with bends, insert view from step 2 + flat pattern view with bend lines
5d.) Part contains sheet metal part that was made by all other tools than "convert to sheet metal", insert view from step 2 + flat pattern view with bend lines
Because GetTypeName2 does not have (or I am missing it) method to distinct 5a-5d, I need other way.
What if the part was not converted from the solid (5d) but has not bends just base flange, like the one below?
I believe you do not need flat pattern in this case in your drawing, is this correct? If so than there are only two options: model with bends and without bends (plate). You can differentiate ones by counting the bend lines in the Bend-Lines sketch under the flat pattern feature (first 2D sketch under the flat pattern):
You are right Artem, when working only with base flange without bends I do not need flat view, just view from selected face, so case that you have described is another case, 5e.).
But still, how to distinct all described cases?
there is no difference between 5b and 5c, both cases have bendlines in it.
You should not have bend lines in the case 5b. You have a sketch but there is no lines in it. All sheet metals will have this sketch, but plates won't have any lines in it.
If BendLineSketch.LinesCount > 0 'not a plate
You are right Artem !!
Thank you very much, bendlines sketch is inserted anyway, but in some cases it's empty, I didn't notice that before.
BTW: Is there less "feature manager traversing" way to get the same effect?
Ok, I've came up with this partial macro:
Dim swApp As SldWorks.SldWorks
Dim Swmodel As SldWorks.ModelDoc2
Dim SwDraw As SldWorks.DrawingDoc
Dim SwView As SldWorks.View
Dim SwPartPathName As String
Dim SwNewDrawPath As String
Dim SwDrawName As String
Dim RetVal As Boolean
Dim SwTemplate As String
Dim SwpaperSize As String
Dim SwPaperWidth As Double
Dim SwPaperHight As Double
Dim swErrors As Long
Dim swWarnings As Long
Dim swModelExtension As SldWorks.ModelDocExtension
Dim Swpart As SldWorks.PartDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim SwFace As SldWorks.Face2
Dim swSheet As SldWorks.Sheet
Dim swSheetPrp As Variant
Dim SwSheetScale As Double
Dim SwViewScale As Double
Dim SwOutline As Variant
Dim SwLwidoku As Double
Dim SwHwidoku As Double
Dim swFeat As SldWorks.Feature
Dim SwSubFeat As SldWorks.Feature
Dim SwSubFeatName As String
Dim i As Integer
Dim j As Integer
'Dim SwTestBlacha As Integer
Set swApp = Application.SldWorks
Set Swmodel = swApp.ActiveDoc
Set Swpart = swApp.ActiveDoc
Set swSelMgr = Swmodel.SelectionManager
Set SwFace = swSelMgr.GetSelectedObject6(0, -1)
swApp.RunCommand swCommands_NormalTo, ""
'Pobiera ścieżkę otwartej cześci/złożenia (Get Path for opened part)
SwPartPathName = Swmodel.GetPathName
'Ustala ścieżkę nowego rysunku (Get new drawing Path)
SwNewDrawPath = Left(Swmodel.GetPathName, InStr(Swmodel.GetPathName, ".") - 1)
SwDrawName = SwNewDrawPath & ".Slddrw"
'Set swFeat = Swmodel.FirstFeature
swFeatCount = Swmodel.GetFeatureCount
Set swFeat = Swmodel.FirstFeature
Do While Not swFeat Is Nothing
Set swFeat = swFeat.GetNextFeature
If swFeat.GetTypeName2 = "FlatPattern" Then
swFeat.SetSuppression2 swUnSuppressFeature, swThisConfiguration, ""
Set SwSubFeat = swFeat.GetFirstSubFeature
Dim swSketch As SldWorks.Sketch
Set swSketch = SwSubFeat.GetSpecificFeature2
Dim swLineCount As Integer
swLineCount = swSketch.GetLineCount2(1)
swFeat.SetSuppression2 swSuppressFeature, swThisConfiguration, ""
But I'm always getting error at line: If swFeat.GetTypeName2 = "FlatPattern" Then, error: object variable or with with variable not set, could you be so kind and tell me, whats wrong?
EDIT: Ok, I found the problem, i supposed to change Set swModel as sldworks.modeldoc2 to Set SwPart as sldworks.partdoc