Copy´nReplace by iLogic

Copy´nReplace by iLogic

thomas_cassanJ7QRS
Explorer Explorer
293 Views
4 Replies
Message 1 of 5

Copy´nReplace by iLogic

thomas_cassanJ7QRS
Explorer
Explorer

Hello Folks

 

I have a iLogic routine that replaces a part in an assembly by copying it incl. the drawing. Same as it was at Compass times..  🙂 

But I have one problem - I need to update the create date. It seems as if there is an insurmountable hurdle for iLogic when it comes to changing the creation date of copied files.
Does anyone have any idea how this could be done with iLogic?
I am happy to provide the code!
Thanks in advance,
Thomas C.

0 Likes
294 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @thomas_cassanJ7QRS.  In your code, within the following block of code:

    srcDoc.SaveAs(newModelPath, True)
    srcDoc.Close()

    occ.Replace(newModelPath, False)

    Dim newDoc As Document =
        ThisApplication.Documents.Open(newModelPath, True)

    SetPartNumber(newDoc, neueNummer)
    SetAuthorAndDesigner(newDoc, currentUser)
    TrySetRevision(newDoc, "-")

    newDoc.Save()
    newDoc.Close()

...where you are setting iProperty values, try inserting this line of code:

'set "Creation Time" iProperty value
newDoc.PropertySets.Item(3).Item(1).Value = Today

The term 'Today' represents a 'Date' data Type with the value of today's date.  You could also use the term 'Now', which works similarly.

Edit:  And since you are changing the 'Part Number' value, it might also be wise to move the line of code for replacing the component occurrence to down after you have changed its iProperty values, and closed it.  Just because the occurrence name usually reflects either the file name, or part number value.  But if you have already 'stabilized' (renamed) the component names in the model browser tree, that would not be necessary.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

thomas_cassanJ7QRS
Explorer
Explorer

Hi Wesley

Thx for your answer - but I tried this before - it seems that iLogic is not able to update the create date of the copied part. It looks like Inventor is blocking it.

Am I wrong? Is there any idea to solve this - my - issue??

thx in andvance

Tom

0 Likes
Message 4 of 5

Curtis_W
Consultant
Consultant

@thomas_cassanJ7QRS , not sure if this is your issue, but Model States can be an issue with the Creation Date property:
https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Creation-Date-iPro...

EESignature

Message 5 of 5

WCrihfield
Mentor
Mentor

If it is not ModelStates related, as Curtis proposed, then it may be related to the volatile timing, since the file was just created, put into an assembly, and visibly opened split seconds apart.  Just speculation, but Inventor may still be updating that property itself, at the same time you are trying to set it.  There may need to be an update of the assembly (or similar intermediate action) after the component replace, before visibly opening the new file.  A common intermediate action to try in tight 'timing' related situations is the ThisApplication.UserInterfaceManager.DoEvents method, which can sometimes provide the pause needed.  Although it is very odd that the other iProperties are getting set OK (I assume), but just not that one.  I have set the value of that date property's value many, many times by code, but maybe just not right after that exact situation (SaveAs -> Replace -> Open).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)