iLogic Issue-Create Drawing from Assembly

iLogic Issue-Create Drawing from Assembly

Anonymous
Not applicable
1,745 Views
7 Replies
Message 1 of 8

iLogic Issue-Create Drawing from Assembly

Anonymous
Not applicable

Pulling my hair out trying to figure out this issue. This is part of a bigger rule but I narrowed it down to this code. From the assembly I am creating a new drawing file using the following code. For troubleshooting purposes the template file is in the same location as the assembly. The issue I am running into is if I open the assembly and run the rule Inventor will lock up and not respond. After restarting Inventor, if I uncomment the messagebox the rule runs just fine. If I comment out the message box again, it still works. The issue comes when I start Inventor for the first time and run the rule with the message box commented out. I've attached a video and dataset. Is there something I'm missing or is this a defect? Any insight would be great!

 

 

'create drawing

Dim oDrawingDoc As DrawingDocument    
Dim DWGTemplate As String = ThisDoc.Path & "\Drawing Template.idw"

'messagebox.show(1)
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, DWGTemplate,True)

 

 

DanV

Inventor 2014 SP1

0 Likes
1,746 Views
7 Replies
Replies (7)
Message 2 of 8

Vladimir.Ananyev
Alumni
Alumni

Have you installed Update 2 for Inventor 2014 Service Pack 1 ?

http://knowledge.autodesk.com/support/inventor-products/downloads#?rows=10&sort=score

 

1) It is better to use fully qualified constants - DocumentTypeEnum.kDrawingDocumentObject.

2) Could you please test simplified command to create new drawing document:

oDrawingDoc = ThisApplication.Documents.Add( _
      DocumentTypeEnum.kDrawingDocumentObject, Nothing, True)

 

cheers


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 8

Anonymous
Not applicable

I installed Update 2, tried your test code and fully qualified the constants and are still getting the same results. Any other ideas? I just don't get it.

 

Thanks,

 

Dan

0 Likes
Message 4 of 8

Anonymous
Not applicable

Vladimir,

 

Any solution for this? Can you log this in as defect if there's no solution.

 

Thanks,

 

Dan

0 Likes
Message 5 of 8

Vladimir.Ananyev
Alumni
Alumni

Could you try the following VBA test:

 

Sub CreateDrawingIssue()
  
  Dim oAsmDoc As AssemblyDocument
  Set oAsmDoc = ThisApplication.ActiveDocument
  Dim sPath As String
  sPath = oAsmDoc.FullFileName
  
  Dim DWGTemplate As String
  DWGTemplate = Left(sPath, InStrRev(sPath, "\")) & "\Drawing Template.idw"
  Debug.Print DWGTemplate
  
  Dim oDrawingDoc As DrawingDocument
  Set oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, DWGTemplate, True)

End Sub

This code is equivalent to your rule.  Do you get any messages?

Best regards,

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 6 of 8

Anonymous
Not applicable

This seems to work. Inventor does not lock up if I run this thru VBA. But if I take this code and run it within iLogic, Inventor locks up just like my code. There's something with iLogic.

0 Likes
Message 7 of 8

Vladimir.Ananyev
Alumni
Alumni

VBA test gives me the attached warning. This dialog waits for user response. In theory this may effect iLogic code.  To check it include Documents.Add method in iLogic rule between SilentOperation = on/off

  ThisApplication.SilentOperation = True
  Dim oDrawingDoc As DrawingDocument
  Set oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, DWGTemplate, True)
  ThisApplication.SilentOperation = False

Let me know the result please.  
Thanks,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 8 of 8

Anonymous
Not applicable

I got that message when I ran it through VBA but I corrected the conflicting styles in the template and re-ran my rules and still are getting the same results. I even ran my rule with no template and still got the same result. As mentioned in the original post, the issue comes when I start Inventor for the first time and run the rule. If a drawing is opened prior to running the rule, it works just fine. What's causing the lockup when the rule is ran after the initial start of Inventor?

 

Thanks for all your help so far.

 

Dan

0 Likes