Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I have an error in this ilogic rule that I can't solve.
Simply when it opens the flat pattern to export it to the chosen folder (folder that is set in the path and has as variable the sheet metal material) it gives me error.
Can anyone help me? Thanks
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
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
oDataMedium1 = ThisApplication.TransientObjects.CreateDataMedium
If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 1200
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2'oOptions.Value("Custom_End_Sheet") = 4
End If
oRefDoc = ThisDrawing.ModelDocument
Dim oPropValue As String
Dim oPropValue1 As String
oPropValue = oRefDoc.PropertySets("Summary Information").Item("Revision Number").Value
iProperties.Value("Summary", "Revision Number") = oPropValue
oPropValue1 = oRefDoc.PropertySets.Item("Design Tracking Properties").Item("Material").Value
iProperties.Value("Custom", "Material Type") = oPropValue1
Rev = iProperties.Value("Summary", "Revision Number")
'get PDF target folder path
Dim oFolder As String
oFolder = "\\SRVDOC2016\pubblica\Foto-Articoli-AS400\"
Dim PDFFolder2 As String
PDFFolder2 = "\\SRVDOC2016\pubblica\Foto-Articoli-AS400_REV_VECCHIE"
'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
Dim Materiale As String = iProperties.Value("Custom", "Material Type")
If Not System.IO.Directory.Exists("\\srvdoc2016\PUBBLICA\PRODUZIONE\TAGLIO LASER\" & Materiale & "\") Then
System.IO.Directory.CreateDirectory("\\srvdoc2016\PUBBLICA\PRODUZIONE\TAGLIO LASER\" & Materiale & "\")
End If
'Set the PDF target file name
oDataMedium.FileName = oFolder & "\" & oFileName & ".pdf"
oDataMedium1.FileName = PDFFolder2 & "\" & oFileName & "-" & Rev &".pdf"
'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium1)
Dim oPart As PartDocument
Dim oPartPath As String
' Get drawing path
oPartPath = ThisDoc.PathAndFileName(False) & ".ipt"
' Set a reference to the target part
oPart = ThisApplication.Documents.ItemByName(oPartPath)
' Open the target part
ThisApplication.Documents.Open(oPartPath)
InventorVb.DocumentUpdate(True)
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oType As String
oType = oDoc.DocumentSubType.DocumentSubTypeID
Dim currentStyle As String
currentStyle = iProperties.Material
If oType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
'Set your filepath here:
SETFilePath = "C:\temp\" & oPropValue1
Dim partDoc As PartDocument
'Check for flat pattern >> create one if needed
Dim oDoc01 As PartDocument
oDoc01 = ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oDoc01.ComponentDefinition
If oCompDef.HasFlatPattern = False Then
oCompDef.Unfold
Else
oCompDef.FlatPattern.Edit
End If
'DXF Settings
Dim sOut As String
Dim sPATH As String
sOut = "FLAT PATTERN DXF?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"
Dim sFname As String
pFname = ThisDoc.FileName(False) & ".ipt"
'Export the DXF and fold the model back up
oCompDef.DataIO.WriteDataToFile( sOut, SETFilePath & "\" & ThisDoc.FileName(False) & ".dwg")
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oDoc01.ComponentDefinition
oSMDef.FlatPattern.ExitEdit
Else
GoTo Update
End If
Update :
InventorVb.DocumentUpdate(False)
opendoc = ThisDoc.PathAndFileName()'saves doc path and file name
doc = ThisApplication.Documents.Open(opendoc & ".ipt")'saves 'doc' as the open application from 'opendoc' adding the extension '.iam'
doc.Close 'closes the indicated document 'doc'
'System.Threading.Thread.CurrentThread.Sleep(2000)
InventorVb.DocumentUpdate(False)
InventorVb.DocumentUpdate(False)
'iLogicVb.RunExternalRule("DWG_LOGICO")
Danilo "DannyGi" G.
Mechanical design engineer and product developer
Mechanical design engineer and product developer
Solved! Go to Solution.