Hello,
I am trying to use iLogic to help me create the file types I need to give to my vendors once I have created a drawing.
In the .idw file I have a rule that creates a .pdf file and .dwg file. I also want it to activate a rule I have in the .ipt file that creates a .dxf file. Any ideas?
.idw code
trigger = iTrigger0 oType=Left(ThisDoc.FileName(False),3) GoExcel.Open("S:\DRAWINGS\Folder Types.xlsx", "Sheet1") For rowPN = 1 To 200 If (GoExcel.CellValue("A" & rowPN) = oType) Then oFile = GoExcel.CellValue("C" & rowPN) Exit For End If Next oFolder = "S:\DRAWINGS\NOT RELEASED\" & oFile If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If ThisDoc.Document.SaveAs(oFolder & "\" & ThisDoc.FileName(False) & (".pdf") , True) ThisDoc.Document.SaveAs(oFolder & "\" & ThisDoc.FileName(False) & (".dwg") , True) oSM=ThisDoc.PathAndFileName(False)&".ipt" iLogicVb.RunRule(oSM,"DXF") MessageBox.Show(oFolder, "File Saved To")
.ipt code
Sub Main ExportDxf() End Sub Public Sub ExportDxf() oType=Left(ThisDoc.FileName(False),3) GoExcel.Open("S:\DRAWINGS\Folder Types.xlsx", "Sheet1") For rowPN = 1 To 200 If (GoExcel.CellValue("A" & rowPN) = oType) Then oFile = GoExcel.CellValue("C" & rowPN) Exit For End If Next oFolder = "S:\DRAWINGS\NOT RELEASED\" & oFile If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 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 sFname = oFolder & "\" & ThisDoc.FileName(False) & ".dxf" sOut = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=0&InteriorProfilesLayer=0&InvisibleLayers=IV_UNCONSUMEND_SKETCHES;IV_ALTREP?_BACK;IV_ALTREP_FRONT;IV_ARC_CENTERS;IV_TOOL_CENTE?R_DOWN;IV_TOOL_CENTER;IV_ROLL;IV_TANGENT;IV?_BEND;IV_BEND_DOWN;IV_ROLL_TANGENT;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN&SplineTolerance Double 0.01" oCompDef.DataIO.WriteDataToFile( sOut, sFname) End Sub
Solved! Go to Solution.
Solved by thomaskennedy. Go to Solution.
This should work for you :
Dim iLogicAuto As Object = iLogicVb.Automation If (iLogicAuto Is Nothing) Then Exit Sub Dim doc As Document = ThisDrawing.ModelDocument Dim ruleName As String = "test" Dim rule As Object = iLogicAuto.GetRule(doc, ruleName) 'get the rule Dim i As Integer = iLogicAuto.RunRuleDirect(rule) 'run the rule
That rule will :
- Get the first model document in the drawing
- Defines a rule name (the rule to be fired in the ipt)
- Gets the rule
- Fires the rule.
Hope this helps,
Tom
Hello Tom,
I tried using that code, it works to pull and run the rule in the .ipt file but I get a error now.
I do not get this error when I run the rule directly from the .ipt file.
Error Message:
Error in rule: Rule1, in document: K550008.ipt
Unable to cast COM object of type 'Inventor._DocumentClass' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Any ideas of what is going on? I am not a great programmer and this error is confusing me.
Ah OK, try changing this line in your ipt :
oDoc = ThisApplication.ActiveDocument
to :
oDoc = ThisDoc.Document
ThisDoc.Document gets the document that the rule is in, whereas ThisApplication.ActiveDocument gets the active document, which in this case would've been your drawing document.
Does that work?
Would be possible to activate one rule in each part of one assembly that is the base view of th eIDW ?
Like if i put one registry in a part list, and then it runs a rule on each ipt to create a custom property with this registry, is that possible ? My problem here is how to make this link with one specific field of the parts list.
Thanks
Túlio Barata