Use iLogic to create a .stp of a 3D model and create a .pdf of drawing.

Use iLogic to create a .stp of a 3D model and create a .pdf of drawing.

Anonymous
Not applicable
430 Views
2 Replies
Message 1 of 3

Use iLogic to create a .stp of a 3D model and create a .pdf of drawing.

Anonymous
Not applicable

I have a iLogic rule for creating a .pdf from a drawing file. However, I am looking to adapt it so that I am able to open a model .ipt or .iam and run the rule. I need the rule to create a .stp of the model, a .pdf of the 2D drawing and a .dxf of one sheet of the drawing. These 3 files will need to be saved to a different path as well.

 

Any ideas on this?

0 Likes
431 Views
2 Replies
Replies (2)
Message 2 of 3

Tony_Yates
Advocate
Advocate

This is how we do it:-

Using this as the main rule

 

Dim iLogicAuto As Object = iLogicVb.Automation
If (iLogicAuto Is Nothing) Then Exit Sub
 
Dim doc As Document = ThisDrawing.ModelDocument

oFileName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
oPath = IO.Path.GetDirectoryName(ThisDrawing.ModelDocument.FullFileName)
'MessageBox.Show(oPath, "Title")
iLogicVb.RunExternalRule("PDF - Rev Laser Cut Export - Multi Sheet")
ThisDoc.Launch(oPath & "/" & oFileName)
iLogicVb.RunExternalRule("PDF - STP Export from IDW")
iLogicVb.RunExternalRule("PDF - DXF Export from IDW")

doc.Close

 

this is the "PDF - Rev Laser cut Export - Multi sheet" rule  

'------start of iLogic-------
oPath = "c:\vault workspace\Engineering\01 Drawing Folder\"
oFileName = ThisDoc.FileName(False) 'without extension
oRevNum = iProperties.Value("Project", "Revision Number")
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium



'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 'no longer required in IV2019
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 800
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
'End If 'no longer required in IV2019



'get PDF target folder path
oFolder = oPath

'Check for the PDF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
    System.IO.Directory.CreateDirectory(oFolder)
End If

 'Set the PDF target file name
oDataMedium.FileName = oFolder & "\" & oFileName & "_" & oRevNum & " Laser Cut" & ".pdf"

'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

'MessageBox.Show("PDF saved", "File Save")

'------end of iLogic-------









 

change opath to where you want it.

 

This is  "PDF - STP Export from IDW" rule

'Dim oDoc As PartDocument
'oDoc = ThisDoc.ModelDocument

'ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".stp"), True)
PARTNUMBER = iProperties.Value("Project", "Part Number")
strFolder = "C:\Vault Workspace\Engineering\01 Drawing Folder\" & PARTNUMBER

oRevNum = iProperties.Value("Project", "Revision Number")
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

ThisDoc.ModelDocument.SaveAs(strFolder &  "_" & oRevNum & " Laser Cut" & (".stp") , True)




change strFolder to where you want it to go.

 

This is the "PDF - DXF Export from IDW" rule

 

oPath = "C:\Vault Workspace\Engineering\01 Drawing Folder"
oRevNum = iProperties.Value("Project", "Revision Number")
PARTNUMBER = iProperties.Value("Project", "Part Number")

'get DXF target folder path
oFolder = oPath
Dim oDoc As PartDocument

oDoc = ThisDoc.ModelDocument
'oDoc = ThisApplication.ModelDocument

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDoc.ComponentDefinition

If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If

Dim sOut As String
If ExportInner = True Then
sOut = "FLAT PATTERN DWG?AcadVersion=2000&OuterProfileLayer=Burn&InteriorProfilesLayer=Burn&InvisibleLayers=IV_UNCONSUMEND_SKETCHES;IV_ALTREP_BACK;IV_ALTREP_FRONT;IV_ARC_CENTERS;IV_TOOL_CENTER_DOWN;IV_TOOL_CENTER;IV_ARC_CENTERS;IV_TANGENT;IV_BEND;IV_BEND_DOWN&SplineTolerance Double 0.01"
Else
sOut = "FLAT PATTERN DWG?AcadVersion=2000&OuterProfileLayer=Burn&InteriorProfilesLayer=Burn&InvisibleLayers=IV_UNCONSUMEND_SKETCHES;IV_ALTREP_BACK;IV_ALTREP_FRONT;IV_ARC_CENTERS;IV_TOOL_CENTER_DOWN;IV_TOOL_CENTER;IV_ARC_CENTERS;IV_TANGENT;IV_BEND;IV_BEND_DOWN&SplineTolerance Double 0.01"
End If


'Check for the DXF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If

'Get document's full file name
Dim sFname As String
sFname = ThisDoc.FileName(False) 'without extension

'The file format will depend on the extension'Set file name extension to ".DXF"

'sFname = oPath & "\" & sFname & oRevNum & ".dxf"
sFname = oPath & "\" & PARTNUMBER & "_" & oRevNum & " Laser Cut" & ".dxf"
oCompDef.DataIO.WriteDataToFile (sOut, sFname)

 

change opath to where you want it to go. 

 

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Yeah so the only problem I see with this is the .dxf file I want is just a dxf of a sheet we have made on the drawings that is labelled Flat Platterns. This sheet is subtracted from the sheet count. It is scaled so that every flat pattern in the model can fit at 1:1 scale. Any ideas on this?

0 Likes