Jump to content
Developer Wiki and Function Reference Links ×

Adding Button to the Mode Bar


Szary

Recommended Posts

Hello,

I am trying to add an button to the Mode Bar for my tool scripted in python, but I am having some difficulties as I am a newbie.

The description here is not very helpful:

http://developer.vectorworks.net/index.php/VS:vstAddButtonMode

Can you tell me what should be passed in to this function? Or maybe even better, where should I find this info?

I found some description for AddRadioMode:

The string identifier for the image. It should be of the form "ResourceFileNameWithoutExtension/PathOfImageFile".

But I don't know where to put the icon or is the path relative or not?

Even without the proper icon specified the button appears on the mode bar with the red cross as an icon, but when I click it I am getting preferences window and the button disappears after the window is gone. Is this because of the icon problem? Or I am doing something else wrong?

I am actually writing a python script but I think it should be easy enough to convert. Here is the main code:

def PrepModeBar():

vs.vstAddButtonMode("button")

def execute():

theEvent,buttonid = vs.vsoGetEventInfo()

if theEvent == vs.kObjOnInitXProperties:

PrepModeBar()

Any help would be appreciated.

Regards,

Peter

Link to comment

Yes you need a link to an image, in a resource file. This could be one of your own, or even one of the default in Vectorworks available libraries.

Also, your button disappearing is probably because of how the modebar works. I only know how to work with it in the SDK, but the workflow should be the same.

The modebar constantly recreates itself, so you will need to add items to your modebar in one of the available events, it keeps recreating.

Link to comment

Thank you for your reply Hippocode,

Could please explain step by step or give me some example files how to build/find resource file which will have the icon and then link it to the plugin?

I know I ask for much time but I have spent so many hours digging through the documentation, examples and google that I am close to giving up and you are my only hope.

Also I can see there two types of events, object events and tool events, I assume I need the second to built the mode bar?

I changed the script file using binary editor to enable tool events but now the tool is not being selected in VW I only get one event with arguments (3,0,0) I try to respond with vs.vstSetEventInfo(3, 0, 0, 1) but this does not help:/

Kind Regards,

Peter

Link to comment

Thank you for your reply Hippocode,

Could please explain step by step or give me some example files how to build/find resource file which will have the icon and then link it to the plugin?

I know I ask for much time but I have spent so many hours digging through the documentation, examples and google that I am close to giving up and you are my only hope.

Also I can see there two types of events, object events and tool events, I assume I need the second to built the mode bar?

I changed the script file using binary editor to enable tool events but now the tool is not being selected in VW I only get one event with arguments (3,0,0) I try to respond with vs.vstSetEventInfo(3, 0, 0, 1) but this does not help:/

Kind Regards,

Peter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...