Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to define an A-Side for my sheet metal part using VBA and it fails
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
Set oDef = oPartDoc.ComponentDefinition
'Change Document.SubType to Sheetmetal
oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
Dim cd As SheetMetalComponentDefinition
Set cd = oPartDoc.ComponentDefinition
cd.UseSheetMetalStyleThickness = False
cd.Thickness.Value = 0.5
'---Find the biggest face
Dim f As Face
Dim bf As Face
Dim area As Double
For Each f In oDef.SurfaceBodies(1).Faces
' Only care about planar faces
If TypeOf f.Geometry Is Plane And f.Evaluator.area > area Then
Set bf = f
area = f.Evaluator.area
End If
Next
'--- Change the color of the biggest face
Dim oRenderStyle As RenderStyle
Set oRenderStyle = oPartDoc.RenderStyles.Item("Yellow")
Call bf.SetRenderStyle(StyleSourceTypeEnum.kOverrideRenderStyle, oRenderStyle)
oPartDoc.Rebuild2 (True)
'---Define A-Side
Call cd.ASideDefinitions.Add(bf) '<----- Fails here)
Debug.Print cd.ASideDefinitions.Count
If cd.HasFlatPattern = False Then
cd.Unfold
End If
cd.FlatPattern.ExitEdit
it first return this error message and when you cancel it ;
it shows this error
any idea on how to get this to work? the part has no existing flat pattern, even if you first create the flat pattern ad then try to define an A-Side still fails the same way as shown here.
any help is greatly appreciated .
Best,
Ali
Solved! Go to Solution.