Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Issue-Create Drawing from Assembly

7 REPLIES 7
Reply
Message 1 of 8
danvang
1584 Views, 7 Replies

iLogic Issue-Create Drawing from Assembly

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

** If my reply resolves this issue, please choose "Accept as Solution" **
Dan Vang
7 REPLIES 7
Message 2 of 8
Vladimir.Ananyev
in reply to: danvang

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

Message 3 of 8
danvang
in reply to: Vladimir.Ananyev

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

** If my reply resolves this issue, please choose "Accept as Solution" **
Dan Vang
Message 4 of 8
danvang
in reply to: Vladimir.Ananyev

Vladimir,

 

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

 

Thanks,

 

Dan

** If my reply resolves this issue, please choose "Accept as Solution" **
Dan Vang
Message 5 of 8
Vladimir.Ananyev
in reply to: danvang

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

Message 6 of 8
danvang
in reply to: Vladimir.Ananyev

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.

** If my reply resolves this issue, please choose "Accept as Solution" **
Dan Vang
Message 7 of 8
Vladimir.Ananyev
in reply to: danvang

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

Message 8 of 8
danvang
in reply to: Vladimir.Ananyev

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

** If my reply resolves this issue, please choose "Accept as Solution" **
Dan Vang

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report