What is happening to my ilogic?

What is happening to my ilogic?

Anonymous
Not applicable
972 Views
5 Replies
Message 1 of 6

What is happening to my ilogic?

Anonymous
Not applicable

Can someone please help. 

Several of my ilogic codes stopped working. I keep getting errors like this

 

 

System.Runtime.InteropServices.COMException (0x80020003): Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

0 Likes
Accepted solutions (2)
973 Views
5 Replies
Replies (5)
Message 2 of 6

AlexFielder
Advisor
Advisor

Can you share the rule you're running? Some elements of the 2019 API were modified, although I'm not sure what exactly would affect your rule specifically.

0 Likes
Message 3 of 6

Anonymous
Not applicable

 2017.4.3

 

 attached the code that crapped out on me

0 Likes
Message 4 of 6

AlexFielder
Advisor
Advisor

you can click the </> button in the editor and paste the rule into the body of the text reply.

0 Likes
Message 5 of 6

Anonymous
Not applicable
Accepted solution

okay so the previous code is working now. Why I don't know, restarted my computer and now it works.

 

But this code is not working.

It was about two weeks ago. Its suppose to print pdfs from the assembly level. Runs through the end but never makes any pdfs

SyntaxEditor Code Snippet

Sub Main()
'check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If

'define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)

'get user input
RUsure = MessageBox.Show ( _
"This will create a PDF file for all of the asembly components that have drawings files." _
& vbLf & "This rule expects that the drawing file shares the same name and location as the component." _
& vbLf & " " _
& vbLf & "Are you sure you want to create PDF Drawings for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic  - Batch Output PDFs ",MessageBoxButtons.YesNo)

If RUsure = vbNo Then
Return
Else
End If

'- - - - - - - - - - - - -PDF setup - - - - - - - - - - - -
oPath = ThisDoc.Path
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
'oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2'oOptions.Value("Custom_End_Sheet") = 4
End If

'get PDF target folder path
oFolder = oPath & "\" & oAsmName & " PDF Files"

'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
'- - - - - - - - - - - - -

'- - - - - - - - - - - - -Component Drawings - - - - - - - - - - - -'look at the files referenced by the assembly
doc = ThisDoc.Document
    Dim oAssyDef As AssemblyComponentDefinition = doc.ComponentDefinition
    Dim oBOM As BOM = oAssyDef.BOM

    oBOM.StructuredViewEnabled = True
    oBOM.StructuredViewFirstLevelOnly = False

    Dim oBOMView As BOMView = oBOM.BOMViews.Item("Structured")

    Dim oBOMRow As BOMRow
    Dim oCompDef As ComponentDefinition

    For Each oBOMRow In oBOMView.BOMRows

     
       If Not oBOMRow.ChildRows Is Nothing
         Call RecurseBOMRow(oBOMRow, PDFAddIn, oFolder)
      End If
       oCompDef = oBOMRow.ComponentDefinitions.Item(1)
idwPathName = Left(oCompDef.Document.FullDocumentName, Len(oCompDef.Document.FullDocumentName) - 3) & "idw"
'check to see that the model has a drawing of the same path and name 'MessageBox.Show(idwPathName)

If(System.IO.File.Exists(idwPathName)) Then
        Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.Documents.Open(idwPathName, True)
    oFileName = Left(oCompDef.Document.DisplayName, Len(oCompDef.Document.DisplayName) -3)
    
    'INSERT RULE HERE
    iLogicVb.Automation.RunExternalRule(oDrawDoc, "DELETE1")
    iLogicVb.Automation.RunExternalRule(oDrawDoc, "DELETE2")

    
    
    On Error Resume Next ' if PDF exists and is open or read only, resume next
     'Set the PDF target file name
    oDataMedium.FileName = oFolder & "\" & oFileName & "pdf"
        'Write out the PDF
    Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium)
    
    'close the file
    oDrawDoc.Close(True)
    
Else
'If the model has no drawing of the same path and name - do nothing
End If
    Next



'- - - - - - - - - - - - -
Call PrintTopLevel()
MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic")
'open the folder where the new ffiles are saved
Shell("explorer.exe " & oFolder,vbNormalFocus)
End Sub

Sub RecurseBOMRow(oBOMRow As BOMRow, PDFAddIn As ApplicationAddIn, oFolder As String)
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
   For Each oBOMRow In oBOMRow.ChildRows
     Dim oCompDef As ComponentDefinition
     oCompDef = oBOMRow.ComponentDefinitions.Item(1)

idwPathName = Left(oCompDef.Document.FullDocumentName, Len(oCompDef.Document.FullDocumentName) - 3) & "idw"

'check to see that the model has a drawing of the same path and name 
If(System.IO.File.Exists(idwPathName)) Then
        Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.Documents.Open(idwPathName, True)
    oFileName = Left(oCompDef.Document.DisplayName, Len(oCompDef.Document.DisplayName) -3)
   
    'INSERT RULE HERE
   iLogicVb.Automation.RunExternalRule(oDrawDoc, "DELETE1")
    iLogicVb.Automation.RunExternalRule(oDrawDoc, "DELETE2")

    
    
    'On Error Resume Next ' if PDF exists and is open or read only, resume next
     'Set the PDF target file name
    oDataMedium.FileName = oFolder & "\" & oFileName & "pdf"
        'Write out the PDF
    Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium)
    
    'close the file
    oDrawDoc.Close(True)
    
Else
'If the model has no drawing of the same path and name - do nothing
End If
     If Not oBOMRow.ChildRows Is Nothing
          Call RecurseBOMRow(oBOMRow, PDFAddIn, oFolder)
     End If
   Next
End Sub
'- - - - - - - - - - - - -

'- - - - - - - - - - - - -Top Level Drawing - - - - - - - - - - - -
Sub PrintTopLevel()
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

oAsmDrawing = Left(ThisApplication.ActiveDocument.FullDocumentName, Len(ThisApplication.ActiveDocument.FullDocumentName) - 3) & "idw"
oAsmDrawingDoc = ThisApplication.Documents.Open(oAsmDrawing, True)
oAsmDrawingName = Left(oAsmDrawingDoc.DisplayName, Len(oAsmDrawingDoc.DisplayName) -3)
'write out the PDF for the Top Level Assembly Drawing file
On Error Resume Next ' if PDF exists and is open or read only, resume next
 'Set the PDF target file name
 oFolder = "C:\Work\Projects\24000\24373\24373-007-7000 PDF Files"
oDataMedium.FileName = oFolder & "\" & oAsmDrawingName & "pdf"
'Write out the PDF
Call PDFAddIn.SaveCopyAs(oAsmDrawingDoc, oContext, oOptions, oDataMedium)
'Close the top level drawing
oAsmDrawingDoc.Close
End Sub


0 Likes
Message 6 of 6

Anonymous
Not applicable
Accepted solution

So I found out why this code was not working.

This code is based on the fact the simple file extensions. (.iam, .ipt).

I turned off the function to see the file extensions in the folder options. 

0 Likes