Macros: Point Snaps in Sketch

Macros: Point Snaps in Sketch

ryabinina_olya
Contributor Contributor
773 Views
3 Replies
Message 1 of 4

Macros: Point Snaps in Sketch

ryabinina_olya
Contributor
Contributor

Hello!

 

I use the command "Point Snaps - Endpoint" from the context menu. How I can call this command in Macros?GTpsjD4K8_0.jpg

 

Can someone help me with this?

Olga Ryabinina
Professor Assistant in Voronezh State Technical University
0 Likes
Accepted solutions (1)
774 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor

For future post if you put the request in the customization forum you might have more users familiar with programming questions and trouble shooting etc. 

 

Searching for the right command can be hit and miss, look at the command name and search for it using notepad find method. When activating the command ensure you are in the right area where the command is exposed.

 

Here is how you run a command and also how to get the command list similar to below https://modthemachine.typepad.com/my_weblog/2009/03/running-commands-using-the-api.html

 

https://clintbrown.co.uk/2020/03/14/ilogic-running-commands-using-the-api/amp/

 

 

This is what the command list will look like. Search endpoint, found correct snippet see picture. 

 

https://github.com/AlexFielder/iLogic/blob/master/CommandNames.txt

 

Here is ilogic version. 

Dim oCDs As ControlDefinitions
 oCDs = ThisApplication.CommandManager.ControlDefinitions
  
Dim oCD As ControlDefinition
 oCD = oCDs("GetPointEndpoint") 
'test to see we have the correct button 'oCD.Enabled = True Is active In Right Click Context Menu ' oCD.Enabled = False Is greyed out and deactivated In Right Click Context Menu
'launch command oCD.Execute

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 4

ryabinina_olya
Contributor
Contributor

Thanks!

It works, but I need code for macros, because I want use it in hot key

Olga Ryabinina
Professor Assistant in Voronezh State Technical University
0 Likes
Message 4 of 4

A.Acheson
Mentor
Mentor
Accepted solution

First sub in this article posted previously. Replace command as needed. 

 

https://modthemachine.typepad.com/my_weblog/2009/03/running-commands-using-the-api.html


Public Sub RunLineCommand()

    ' Get the CommandManager object.
    Dim oCommandMgr As CommandManager
    Set oCommandMgr = ThisApplication.CommandManager

    ' Get control definition for the line command.
    Dim oControlDef As ControlDefinition
    Set oControlDef = oCommandMgr.ControlDefinitions.Item("GetPointEndpoint")  ‘place command here

    ' Execute the command.
    Call oControlDef.Execute
End Sub

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes