Szary Posted February 18, 2016 Share Posted February 18, 2016 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 Quote Link to comment
Szary Posted February 23, 2016 Author Share Posted February 23, 2016 I have done further research and maybe my question might be more specific. Do I need to use vwr resource file? http://developer.vectorworks.net/index.php/Vectorworks_VWR_Resources#Compiling_with_BuildVWR_build_step Does anyone have any example with using it with the scripts? And maybe know how to build one? Quote Link to comment
Hippocode Posted February 23, 2016 Share Posted February 23, 2016 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. Quote Link to comment
Szary Posted February 28, 2016 Author Share Posted February 28, 2016 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 Quote Link to comment
Szary Posted February 28, 2016 Author Share Posted February 28, 2016 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 Quote Link to comment
Hippocode Posted February 28, 2016 Share Posted February 28, 2016 http://developer.vectorworks.net/index.php/SDK:Tutorial this page briefly handles a plug-in library for mac/windows. You can just look at the file structure of existing plug-ins in your installation as well. I have no experience with using tool events in VS, but yes I assume those are which you need. Quote Link to comment
Recommended Posts
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.