Problem with iLogic rule for Update Copied Properties

Problem with iLogic rule for Update Copied Properties

l_dalise
Participant Participant
264 Views
4 Replies
Message 1 of 5

Problem with iLogic rule for Update Copied Properties

l_dalise
Participant
Participant

Hi all

 

I've this rule (named CopiaPropietà) in my .idw and i've put the rune in the Event Trigger, After Open Document

Dim oControlDef As ControlDefinition

oControlDef = ThisApplication.CommandManager.ControlDefinitions.​Item("UpdateCopiedModeliPropertiesCmd")

oControlDef.Execute2(True)

 

But when I open the idw, it show me an error

Error on line 5 in rule: CopiaProprietà, in document: DV33072.idw

Errore non specificato. (Exception from HRESULT: 0x80004005 (E_FAIL))

 

I've try to change This 

oControlDef.Execute2(True)

to This

oControlDef.Execute


But it work differently. if I use .Execute it trigger the dialogbox to confirm the update copied properties.

Screenshot_30.png

Instead with .Execute2(True) it show the error after open the document.

 

But if i use Execute2(True), and run the rule manually after open the document, nothing visually happend. None windows pop up.

There is a solution with this?
Maybe i've to put in the event trigger, Before Safe Document, and not in After Open Document?

Thanks all

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

WCrihfield
Mentor
Mentor

Hi @l_dalise.  The main differences between those two codes is the timing and whether or not other stuff that is actively going on within Inventor when this execution is called is interrupted by this call or not.  When using the regular Execute method, that is like using the Execute2 method, then specifying False, instead of True, but the Execute2 version gives you that added control.  Nothing or False means asynchronous (post), while True means synchronous (send).  Sync is like doing processes sequentially or in order, while Async does not wait for other processes/order.

Below are a few random web search results about that topic in computing.

https://medium.com/@function12/understanding-synchronous-vs-asynchronous-execution-and-blocking-vs-n... 

https://refine.dev/blog/synchronous-vs-asynchronous/#introduction 

https://www.revelo.com/blog/synchronous-vs-asynchronous-programming 

If you need to avoid that dialog, then there may be an option that would work for you.  It is called 'Silent Operation'.  While that setting is turned on, code operations that do things that would normally cause dialogs to show, will attempt to suppress those dialogs from showing.  There is an application level setting for this, but I do not recommend using that if you do not have to, because there is an iLogic rule level setting for this that can be used instead, which is safer to use.  When you have that iLogic rule open in the iLogic Rule editor dialog, go to the Options tab (along the top of that dialog), then put a checkmark in the CheckBox beside that option to turn it on.  I use that setting quite a bit in my iLogic rules.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

l_dalise
Participant
Participant

Thanks for the reply @WCrihfield 

 

I've already the Silent Operation Checked, but I notice one more thing...

 

if I open the drawing directly from the Vault (with or without chek out), none error shows. Instead, if I open a drawing from the inventor vault tab (see below), as soon as you open the drawing the error appears. So I think there is something wrong with interactio with the "open drawing from vault" within vault inventor tab and the Rule, maybe.

 

Screenshot_31.png Screenshot_32.png

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Hi @l_dalise.  I am not currently using Vault, and have not used it in the past, so I am not 100% sure about this, but I suspect that when opening the drawing directly from Vault, the drawing will still be ReadOnly.  If that is the case, then it would not allow that command to make changes to that drawing, and that may be why it is throwing an error.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

Also, executing commands is risky in many situations, because they do not know which document you want them to effect.  So, they usually just attempt to effect whichever document that happens to be visibly active on your screen at that moment.  This may still be that assembly, instead of the drawing...not sure.  If that was the case, then the command would not work, because there is no control like that in an assembly.  Just another thought that comes to mind.

 

There are other ways to copy iProperties from a drawing's model to the drawing by code, without using that command.  However, we can not yet access those settings deep within the drawing's document settings, where the individual iProperties are selected for copying.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes