Measure command

Measure command

D.Wheeler3GADA
Advocate Advocate
728 Views
9 Replies
Message 1 of 10

Measure command

D.Wheeler3GADA
Advocate
Advocate

Is there a way to use ilogic to launch the "measure" command within an assembly and enter the measurement into a field on a form? I need to do this without identifying the objects being measured (that is my hang-up), so it could be any distance measured inside the assembly that would have the value entered into the form field... Thanks!

0 Likes
729 Views
9 Replies
Replies (9)
Message 2 of 10

WCrihfield
Mentor
Mentor

Well, the measure command can be launched by executing the ControlDefinition named "AppMeasureDistanceCmd", but I'm not sure how to automate the rest of what you are referring to.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 10

D.Wheeler3GADA
Advocate
Advocate

@WCrihfield ,

           In lieu of populating a form field with the value from the measured distance, I could populate a user parameter with the value...

 

I am having issues trying to launch the measure command using ilogic and "AppMeasureDistanceCmd". The code doesn't error out, but nothing happens when ran.

0 Likes
Message 4 of 10

WCrihfield
Mentor
Mentor

When I put this code into a 'local' iLogic rule, within an assembly, then run the rule, it brings up the Measure tool's dialog (UI) on the model screen.  If this is not working for you, then I'm not sure why.

ThisApplication.CommandManager.ControlDefinitions.Item("AppMeasureDistanceCmd").Execute

But maybe I am not understanding what you are needing here.  There are other ways to measure things by code, without using that user interface tool.  Maybe you need to use the ThisApplication.MeasureTools object, and the methods available through that.  There are also similar methods available in a iLogic rule by simply typing in Measure, followed by a dot, then intellisense will show you the tools available within that.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 10

D.Wheeler3GADA
Advocate
Advocate

@WCrihfield ,

        There was a spelling error in my code. I fixed it and the command runs. Now I need to figure out how to apply the "Minimum Distance" value from the measure command to a user parameter...

 

THANKS!

0 Likes
Message 6 of 10

WCrihfield
Mentor
Mentor

If you are set on using that user interface measure command, then you may have to use something like the System.Windows.Forms.SendKeys.SendWait() method to attempt to navigate that dialog by keyboard keys.  Once you record what minimum keyboard keys you can use to automate copying the value from that dialog you need, you can put that key sequence into the SendWait method as input.  Retrieving that copied data from the 'Clipboard' is another matter for later, once this part is figured out.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 10

Michael.Navara
Advisor
Advisor

I don't have any experience with this, but you can try to use MeasureEvents from Inventor API. Here is a sample code in VBA

0 Likes
Message 8 of 10

D.Wheeler3GADA
Advocate
Advocate

@WCrihfield ,

            Thank you again for all your help/advice! It would appear as though I am starting to get in over my head with the coding involved to get that distance value into a parameter field. While it is not an integral part of what I am trying to accomplish, it would alleviate having to obtain that measurement prior to running the rule...  

 

 

0 Likes
Message 9 of 10

D.Wheeler3GADA
Advocate
Advocate

@Michael.Navara ,

       I am new to coding in Inventor, and I do not know how to create a custom Class Module...

 

Thank you for the links, though!

0 Likes
Message 10 of 10

Michael.Navara
Advisor
Advisor

This is not easy to use it in iLogic, but it works well in Addins. Here is short sample, how to use it. This rule defines custom dialog with MeasureEvents implementation.