AnsweredAssumed Answered

API Saving - existing part vs new

Question asked by Kevin Collins on Jan 27, 2017
Latest reply on Jan 30, 2017 by Kevin Collins

I am hoping some of you genius's can help me.

 

I have a Macro written that runs some code to update configurations and at the end of the code, saves the part.

 

It works great with the exception of one thing.  If my save code reads as follows:

 

boolstatus = swModel.Save3(swSaveAsOptions_Silent, IErrors, IWarnings)

 

...then Solidworks will not save the part if the part is new.

 

If I change it to:

 

boolstatus = swModel.Save3(swSaveAsOptions_SaveReferenced, IErrors, IWarnings)

 

... then it prompts every single part that is read.only to save.

 

I have tried the following:

 

     If swModel.IsOpenedReadOnly Then

         boolstatus = swModel.Save3(swSaveAsOptions_Silent, IErrors, IWarnings)

         Else

         boolstatus = swModel.Save3(swSaveAsOptions_SaveReferenced, IErrors, IWarnings)

         End If

That reduced the number of prompts but did not fix everything.

 

My question is, can this If / Then statement be re-written to say If the part is New, Save Referenced, Else, Save Silent?  The "If the part is new" is the item I'm struggling with as I can't seem to find the code for it.

 

Thanks!

Outcomes