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 to save Inventor dwg but not model

5 REPLIES 5
Reply
Message 1 of 6
gazadder
1637 Views, 5 Replies

Ilogic to save Inventor dwg but not model

Hi,

 

I currently have ilogic code that automatically saves a template Inventor dawing as a job drawing. However the problem I am having is when it does this save it takes forever as it seems to be also saving the linked model also. Is there a way to save this Inventor dwg without saving the linked model? The reason why I do not want this model save is because after the drawing is outputted the user is given options to write part numbers and dxf files if required which requires a model save anyway.

 

Sample of code used:-

 

ThisDoc.Document.SaveAsInventorDWG(ThisDoc.Path & "\2D_DRAWINGS (Inventor dwg)\" & iProperties.Value("Custom", "Drawing No.") & ".DWG", True)

5 REPLIES 5
Message 2 of 6
adam.nagy
in reply to: gazadder

Hi,

 

You are just assuming that the model is being saved because of the long time the save as dwg takes or does the modified date of the model file actually changes?

 

Cheers, 



Adam Nagy
Autodesk Platform Services
Message 3 of 6
gazadder
in reply to: adam.nagy

Sorry I don't know how I forgot about this as this is still an issue.

The line of code used above to save the drawing as an inventor dwg absolutely saves the model too.

Cheers
Message 4 of 6
adam.nagy
in reply to: gazadder

Hi,

 

I could not reproduce the issue. When I used your code inside my drawing it did not save the part it was referencing.

 

Can you reproduce the behaviour with any model? Could you create a most basic, non-confidential one as a sample and send it?

Do you by any chance have any other rules/AddIn running that might do a save on the model? 

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 5 of 6
gazadder
in reply to: adam.nagy

Hi

 

It is an assembly that is refeenced in the drawing and not a part.

 

Just tried it again now. The drawing save takes about 10 - 20 seconds. I then close the template drawing without a save and I can then close the assembly without it prompting for a save. One closed I can re-open it to the state the latest configuration.

 

The drawing save with the configuration I have changed it to takes about 15 seconds.

 

 

Thanks

Message 6 of 6
adam.nagy
in reply to: gazadder

Hi,

 

It's worth checking things in the UI. When I tried to save the drawing to Inventor DWG this dialog popped up:

 

dependentdocuments.png

 

And now I could reproduce the behaviour through the API as well, even with a part document.

So it seems the API behaviour is in sync with what is suggested through the UI - i.e. the part will be saved.

 

To avoid that, we could go through the referenced documents, make them non dirty, save the drawing, then set those docs dirty again.

Sort of the opposite of this solution: http://forums.autodesk.com/t5/Inventor-Customization/How-to-save-all-changes-via-macro/td-p/2823330

 

This seemed to work fine on my side:

 

  Dim doc As Document
  doc = ThisDoc.Document
  
  ' To avoid saving documents
  ' let's set them non-dirty
  Dim rd As Document
  Dim rdd As DocumentDescriptor
  
  ' Collection for dirty documents
  Dim tr As TransientObjects
  tr = ThisApplication.TransientObjects
  
  Dim dd As ObjectCollection
  dd = tr.CreateObjectCollection
    
  ' Make all the referenced documents non-dirty
  For Each rdd In doc.ReferencedDocumentDescriptors
    rd = rdd.ReferencedDocument
    If rd.Dirty Then
      Call dd.Add(rd)
      rd.Dirty = False
    End If
  Next
  
  ' Save
  Call doc.SaveAsInventorDwg( _
    ThisDoc.Path & "\2D_DRAWINGS (Inventor dwg)\" & _
    iProperties.Value("Custom", "Drawing No.") & ".DWG", _
    True)
    
  ' Set the dirty status back
  For Each doc In dd
    doc.Dirty = True
  Next

 

Cheers, 



Adam Nagy
Autodesk Platform Services

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

Post to forums  

Autodesk Design & Make Report