How do I get the selectset properties during command execution?

How do I get the selectset properties during command execution?

lzs013
Advocate Advocate
837 Views
7 Replies
Message 1 of 8

How do I get the selectset properties during command execution?

lzs013
Advocate
Advocate


How do I get the selectset properties during command execution?

My macro code is as follows:

Public Sub selectset()
MsgBox "The cout of selectset is: " & ThisApplication.ActiveDocument.selectset.Count
End Sub


First, I draw a rectangle in the sketch, then I execute the offset command, then I select 2 edges of the rectangle, and finally I run the macro mentioned above, the result is 0.
How to get the selectset property in the command execution process ? For example, get the selectset count during the execution of the offset command.

1.png

0 Likes
Accepted solutions (1)
838 Views
7 Replies
Replies (7)
Message 2 of 8

BrianEkins
Mentor
Mentor

I'm getting 2 back as the count.  Can you provide a Screencast of your specific workflow?  I think maybe there's something you're doing something different that's not explained in your description.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 8

lzs013
Advocate
Advocate

Maybe I didn't explain it clearly. This is my operation process.111.gif

 

 

 

0 Likes
Message 4 of 8

BrianEkins
Mentor
Mentor

Ok, I understand now.  Your original description was correct but I was misled by there only being two lines selected.  The default with the offset command is for it to automatically select a loop.

 

Anyway, the reason that you're not seeing anything in the select set is that when a command is running it has its own private selection and you don't have access to it.  The public select set is the set of entities that have been selected using the default Select command.  The Select command is the command that's active when no other command is running.  Pressing the Escape key causes the Select command to start and forces the currently running command to abort.

 

I'm not sure what you're trying to accomplish but in general, it's not possible to interact with other commands while they're running.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 8

lzs013
Advocate
Advocate

Thank you for your reply. My current attempt is to replace the interactive task in the Inventor command execution with vba instead of mouse orkeyboard.
I have a successful attempt. I use vba instead of the keyboard interaction process. When using sketch commands such as line and circle, I can use the vba hotkey to quickly position the first point to the origin. code show as below.
You said that the Inventor command can't interact with other commands during the running process. So we can use VBA to control the mouse and keyboard to participate in the interaction. But how to control the interactive events during the execution of the Inventor command via VBA? For example, use VBA to control the mouse to capture a sketch point. I don't have any clues, I hope everyone can provide some advice. thank you very much!

 

 

Sub SketchOnZero()
t = Timer
While Timer < t + 0.5
DoEvents
Wend
SendKeys "{TAB}0{TAB}0{ENTER}"
End Sub

 

222.gif

0 Likes
Message 6 of 8

BrianEkins
Mentor
Mentor
Accepted solution

You can mimic doing user input by driving the mouse and keyboard but I think you will always be unsatisfied with the results.  The API provides the same functionality as the user-interface but in a way that makes it easier to use through a programming language.  I would suggest looking at the API documentation.  There are some overview topics but there are also quite a few small VBA samples.  The samples demonstrating working with sketches might be especially useful.

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-DE98632B-3DC0-422B-A1C6-8A5A15C99E11

 

SketchSamples.png

 

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 7 of 8

dgreatice
Collaborator
Collaborator

Hi,

 

SelectSet is not member of Thisapplication,

SelectSet is member of Document

 

so change become:

Dim oDoc as document

Set oDoc = Thisapplication.ActiveDocument

 

...oDoc.SelectSet.Count...

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 8 of 8

lzs013
Advocate
Advocate

THX!

0 Likes