Event trigger not completing rule

Event trigger not completing rule

DJFore
Advocate Advocate
654 Views
3 Replies
Message 1 of 4

Event trigger not completing rule

DJFore
Advocate
Advocate

I have a rule with some code I found online that resorts the hole chart on a drawing. I am trying to activate it to resort right before a save so that my sequence of letters/numbers is correct before it is saved and printed. My problem is I have tested the rule and it is running "I placed a message in it before and after the code and they both showed up" but the code is not doing the resort. The code is correct because it will resort every time if you run it manually (right click run rule) just not with a event trigger. Any suggestions? I have attached the code and showing I have it in my event trigger. Another wrench in it I found when testing is if I run it before the save and after the save it resorts perfectly just not if it is run only before. 

Event trigger.JPG

Dim drawDoc As DrawingDocument
drawDoc = ThisApplication.ActiveDocument
Dim currentSheet As Sheet
currentSheet = drawDoc.ActiveSheet
' Get the hole table to sort.
Dim table As HoleTable
table = currentSheet.HoleTables.Item(1)
' Add it to the select set.
drawDoc.SelectSet.Clear
drawDoc.SelectSet.Select(table)
' Get the re-sort command and execute it.
ThisApplication.CommandManager.ControlDefinitions.​Item("DrawingHoleTableResortCtxCmd").Execute
0 Likes
Accepted solutions (1)
655 Views
3 Replies
Replies (3)
Message 2 of 4

JaneFan
Autodesk
Autodesk

Hello @DJFore,

 

I tried with your code but didn't reproduce the issue.

Do you set event trigger in This Document level? And if you add line in the rule: MsgBox("Rule is run"), can you see the message pop up when saving document?

Doc.png




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 4

DJFore
Advocate
Advocate

I have set it in the document level and I did try it with a message and it did show up. When the rule is run through the trigger it highlights it (looks like you have clicked the table) but it doesn't actually resort. But if I run the rule manually it works fine. I tried putting the code in a stock template that came with inventor thinking maybe it was some other code conflicting with it but I get the same results with it as well. Here is the fun part we are trying to run this off of an assembly where we are calling out port locations in a panel and it does not work but I tried rerunning the same setup with just a ipt file with holes in it and it works with the trigger just fine. So I believe that it is something with the triggering of a hole chart associated to a assembly that is not resorting.

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi @DJFore,

 

I was able to resort hole table using same code. Go through the following screencast.

 

Used drawing document and assembly also attached with this post.

 

Before_running.JPG

 

Hole table - Before saving the drawing document.

 

After_running.JPG

 

Hole Table - After saving the drawing document.

 

 
Please feel free to contact if there is any doubt.
 
If solves problem, click on "Accept as solution" / give a "Kudo".
 
Thanks and regards,

CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes