iLogic Rule to auto create DXF drawing from Sheet Metal part

iLogic Rule to auto create DXF drawing from Sheet Metal part

ekaj
Explorer Explorer
413 Views
0 Replies
Message 1 of 1

iLogic Rule to auto create DXF drawing from Sheet Metal part

ekaj
Explorer
Explorer

Hi there,

 

I'm working on a code to do the following:

 

Check if there's a flat pattern

Create flat pattern

Create dxf drawing

place the flat pattern view at 1:1 scale

Save Copy As original file name, type .dxf, option File Version AutoCAD R12/LT 2 DXF

 

I've compiled a script from various other posts to the forum as well as the API Help, however I'm not getting any meaningful results. At this point I'm still struggling to get the flat view placed on the drawing. 

 

Any help would be greatly appreciated.

 

Here's my current script:

 

Dim oPartDoc As Document
Dim oSheet As Sheet
Dim oTG As TransientGeometry
Dim oView0 As DrawingView
Dim oScale As Double


'Ask to create drawing?
AskCreateDrawing=MsgBox("Would you like to Create a DXF for this part?", vbYesNo,"Drawing Selection")
If AskCreateDrawing = vbYes Then

oPartDoc = ThisDoc.Document

'Check for flat pattern >> create one if needed
Dim partDoc As PartDocument
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDoc.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If

'Rotate Model to correct view
Dim oCamera As Camera
oCamera = ThisApplication.ActiveView.Camera
oCamera.ViewOrientationType = 10764 'Front View
oCamera.Apply
	
'Define IDW Template File Location
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "X:\Midland\Inventor 2018\Templates\DXF2018.idw", True)

'oScale = InputBox("Enter Desired Scale - AS A DECIMAL", "Set Drawing Scale", "1")
'oScale = 1

'Centre of Drawing Border
X_Pos = 100
Y_Pos = 100
	
'Define 2d views
oPoint0 = ThisApplication.TransientGeometry.CreatePoint2d(X_Pos, Y_Pos)				'create flat view
oSheet = oDrawingDoc.Sheets.Item(1)

'Set Flat View
Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
Dim oBaseViewOptions As NameValueMap
     oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap

    ' Set the options to use when creating the base view.
   Call  oBaseViewOptions.Add("SheetMetalFoldedModel", False)


'oBaseView = 
oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint0, 1.0, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, , ,oBaseViewOptions ) 
End If
0 Likes
414 Views
0 Replies
Replies (0)