- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I tried this code but unfortunately an error occurred
' Declare document variables
Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
If oAsmDoc.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("This script is only valid for assembly documents.", "Invalid Document Type")
Return
End If
' Set the template path and create a new drawing document
Dim oTemplatePath As String = ThisApplication.FileOptions.TemplatesPath
Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Add( _
DocumentTypeEnum.kDrawingDocumentObject, oTemplatePath & "\abb_a3.idw", True)
' Add an assembly view to the drawing
Dim oSheet As Sheet = oDrawingDoc.Sheets(1)
Dim oBaseView As DrawingView
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oBaseViewPoint As Point2d = oTG.CreatePoint2d(2, 2) ' Position of the base view on the sheet
oBaseView = oSheet.DrawingViews.AddBaseView(
oAsmDoc,
oBaseViewPoint,
0.1,
ViewOrientationTypeEnum.kDefaultViewOrientation,
DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
' Loop through all components in the assembly to find sheet metal components
For Each oCompOcc As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences
If TypeOf oCompOcc.Definition Is SheetMetalComponentDefinition Then
Dim oSMDef As SheetMetalComponentDefinition = oCompOcc.Definition
' Check if the sheet metal component has a flat pattern
If oSMDef.HasFlatPattern Then
' Define the placement point for the flat pattern view
Dim oFlatPatternPoint As Point2d = oTG.CreatePoint2d(2, 12) ' Adjust position as necessary
' Define flat pattern view options inline
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Add("SheetMetalFoldedModel", False) ' Specify flat pattern
' Add the flat pattern view to the sheet
Dim oFlatPatternView As DrawingView = oSheet.DrawingViews.AddBaseView(
oCompOcc,
oFlatPatternPoint,
0.25,
ViewOrientationTypeEnum.kDefaultViewOrientation,
DrawingViewStyleEnum.kFromBaseDrawingViewStyle,
Nothing, Nothing, oOptions)
End If
End If
Next
' Update the drawing to reflect all changes
oDrawingDoc.Update()
Hello,
At work I must make drawings for production. If an Assembly or Subassy has a Sheetmetal part, then they need a Flat pattern View too.
I would like to generate a drawing from an assembly Model with 4 views. Front, right and top and it should check if an occurrence is a Sheetmetal with a flat pattern then show the flat pattern too, as a 4th view.
I would use it only in assembly where I know there is only one Sheetmetal part among other buy parts i.e. pem’s, cable support etc.
I found a lot of code that generates views with flatpattern but works only for parts.
Can someone please help me? Any help would be very appreciated!
----------------------------------------
It should look something like this:
Solved! Go to Solution.