API: generating Unfolded view
API: generating Unfolded view
(OP)
The 'create flat pattern view from Model view" call runs too slowly; and is not needed; Im to be exporting the unfolded geom from the drawing view.
I know that just suppressing the flat pattern, or suppressing the process bends runs quicker, but I cannot figure out how to, from code, set the 'normal to' whatever plane was used to create the Flat-Pettern or 'Process-Bends' feature.
Im unable to get the plane reference from 2001 (not plus) or earlier, and while I can manually select the sketch subfeature and then click 'normal to', I am unable to select the SUB feature thru code - the selection seems to stay on the 'parent' feature.
Any ideas/workarounds? Its gotta be 2001 compatible, no 20001 plus calls ...
I know that just suppressing the flat pattern, or suppressing the process bends runs quicker, but I cannot figure out how to, from code, set the 'normal to' whatever plane was used to create the Flat-Pettern or 'Process-Bends' feature.
Im unable to get the plane reference from 2001 (not plus) or earlier, and while I can manually select the sketch subfeature and then click 'normal to', I am unable to select the SUB feature thru code - the selection seems to stay on the 'parent' feature.
Any ideas/workarounds? Its gotta be 2001 compatible, no 20001 plus calls ...






RE: API: generating Unfolded view
I hope that helps,
Scott Baugh, CSWP
credence69@REMOVEhotmail.com
http://home.insightbb.com/~scott.baugh/
RE: API: generating Unfolded view
example code
Part.ShowNamedView2 "*Top", 5
Bill Briggs, CSWP
RE: API: generating Unfolded view
Pass the routine a ModelDoc object, and it will Flatten the model, and return a Boolean success code:
'---------------------------------------------------------------------------------------
' Procedure : Flatten
' DateTime : 4/8/2002 20:33
' Author : rocheey
' Purpose : Flattens a Sheet metal Model, and sets the flattened face to
' normal.
' Comments : Pass the routine a Partdoc/ModelDoc and it will attempt to
' suppress the feature. The Function returns TRUE if successful.
'
'---------------------------------------------------------------------------------------
'
Function Flatten(ModelDoc As Object) As Boolean
Const ParseString As String = "FlatPatternProcessBends" ' CASE SENSITIVE! Do Not Change!
Const NormalView As String = "*Normal To"
Const swDocPART As Long = 1
Dim featCount As Long
Dim Feat As Object, SubFeat As Object
Dim featname As String
Dim Success As Boolean
' check DocType, make sure not AssemblyDoc or DrawingDoc
If ModelDoc.getType <> swDocPART Then Exit Function ' return 0
featCount = ModelDoc.GetFeatureCount ' get number of features to Loop thru
For I% = featCount To 1 Step -1 ' Loop backwards thru the features (starting at bottom)
Set Feat = ModelDoc.FeatureByPositionReverse(featCount - I)
featname = Feat.GetTypeName ' get name of feature TYPE, niot feature name
FoundFeature% = InStr(ParseString, featname) ' is it one of our features?
If FoundFeature% Then
MainFeatName$ = Feat.Name ' yessir, I believe it is.
Exit For ' no sense in looking any further
End If
Next I%
If FoundFeature% = 0 Then Exit Function ' If not Sheet metal related, get outta here
Feat.select (False) ' select the Feature, and toggle suppression in our main feature
If FoundFeature% = 1 Then 'Flat Pattern
If Feat.IsSuppressed Then ' Must UNsuppress flat pattern
Success = ModelDoc.EditUnsuppress2 ' unsupress FLATPATTERN,
Else
Success = True ' its already been done for us :)
End If
If Not Success Then Exit Function
ElseIf FoundFeature% = 12 Then ' Process bends
If Not (Feat.IsSuppressed) Then ' Must SUPPRESS Process Bends
Success = ModelDoc.Editsuppress2 ' Suppress Feature
Else
Success = True ' its already been done for us :)
End If
If Not Success Then Exit Function
End If
' Now select the first subfeature
Set SubFeat = Feat.GetFirstSubFeature
Do While Not SubFeat Is Nothing ' While we have a valid Sub-feature
featname = SubFeat.GetTypeName
If featname = "ProfileFeature" Then ' we have our man
SubFeatName$ = SubFeat.Name
FoundFeat% = 1
Exit Do
End If
Set SubFeat = SubFeat.GetNextSubFeature
Loop ' Continue until the last Sub-feature is done
If FoundFeat% = 0 Then Exit Function
ModelDoc.ClearSelection ' clear the selection object
Success = ModelDoc.SelectByID(SubFeatName$, "SKETCH", 0, 0, 0) ' select the sub feature sketch
ModelDoc.ShowNamedView2 NormalView, 0
Flatten = Success
End Function
RE: API: generating Unfolded view
Bill,
>I need to create a view normal to a plane. Is there a way to do this
through the
>API?
you will have to first select the plane and then call:
rocheey, you may be able to select the sktch and do this also
ModelDoc2::ShowNamedView2("*Normal To")
ModelDoc2::NameView
Kind regards,
Trevor D'Arcy-Evans
APIsupportEU@SolidWorks.com
SolidWorks API Support Europe
+44 1223 346904
Bill Briggs, CSWP
bbriggs@cybllings.com
www.cybllings.com
RE: API: generating Unfolded view