twk Posted June 17, 2023 Share Posted June 17, 2023 https://developer.vectorworks.net/index.php/VS:CreateCheckBox2 https://developer.vectorworks.net/index.php/VS:CreateRadioButton2 These two dialog control items were added in VW2023, however setting an icon for their display doesn't seem to be working. Previous similar dialog items icons were able to be set by utilising the resource path in the .vwr location, however it doesn't seem to be working for these ones. And also, I can't seem to see an example of this type of control in any vectorworks' dialogs in any of their stock tools/commands. If you look at my code below, the vs.CreateImagePushButton dialog control seems to work by using the icon path 'Vectorworks/Images/Standard Images/Layers.png', however that same path doesnt work for either CreateCheckBox2 or CreateRadioButton2. Anyone have any ideas before I open a bug ticket? @JBenghiat @MullinRJ @Jesse Cogswell @Vlado @Pat Stanford import vs layer_icon_path = 'Vectorworks/Images/Standard Images/Layers.png' SetupDialogC = 12255 # A predefined constant value that is passed to the dialog event handler subroutine when a modern custom dialog is initially displayed onscreen. SetdownDialogC = 12256 # This constant is passed to the event handler routine to signal dialog setdown. ResizeDialogC = 12611 # This constant is passed to the event handler routine to signal the dialog has been resized. DisplayDialogHelpC = 12916 # This constant is passed to the event handler routine to signal the dialog that it should display its contextual help using the help string given by the Contextual Help Manager menu. DialogTimerEventMessageC = 13028 # This constant represents the message that is sent periodically to a dialog handler after it has been registered to receive timer events. LeftButtonC = 12605 # This constant is used as a control ID when a button must appear in the lower left corner of a dialog. dialog_id = vs.CreateLayout('Dialog Icons Test', False, 'Ok', 'Cancel') vs.CreateCheckBox2(dialog_id, 5, 'Image TextBox', layer_icon_path) vs.CreatePushButton(dialog_id, 6, 'Push Button') vs.CreateImagePushButton(dialog_id, 7, 50, layer_icon_path) vs.SetFirstLayoutItem(dialog_id, 5) vs.SetBelowItem(dialog_id, 5, 6, 0, 0) vs.SetBelowItem(dialog_id, 6, 7, 0, 0) def dialog_handler(item, data): if item == SetupDialogC: pass elif item == 1: pass elif item == 2: pass vs.RunLayoutDialog(dialog_id, dialog_handler) Quote Link to comment
MullinRJ Posted June 17, 2023 Share Posted June 17, 2023 @tui_k, Using your code on a Mac I get : but I used: vs.CreateRadioButton2(dialog_id, 6, 'Push Button', layer_icon_path) instead of: vs.CreatePushButton(dialog_id, 6, 'Push Button') Perhaps it's a Mac/PC thing. I'll try on a PC, but it may take a while. Raymond 1 Quote Link to comment
Pat Stanford Posted June 17, 2023 Share Posted June 17, 2023 I'm don't know, but that path seems not right to me. It seems like it should either need more path at the front to determine the actual file location in the OS, or it should be more relative and not need the Vectorworks. Maybe try using GetFolderPath to get the path to the Application Folder and then append the rest of your path? HTH Quote Link to comment
MullinRJ Posted June 17, 2023 Share Posted June 17, 2023 @Pat Stanford, The path is INSIDE the VW app. It took me a while to find it, too. Raymond Quote Link to comment
Pat Stanford Posted June 17, 2023 Share Posted June 17, 2023 I got that the path is inside the VW Package. But how will it know how to find the VW Package without the full OS folder path? ~/Applications/Vectorworks/2023/ Quote Link to comment
MullinRJ Posted June 17, 2023 Share Posted June 17, 2023 it's actually inside the VW Application, in a resource file. Quote Link to comment
Jesse Cogswell Posted June 17, 2023 Share Posted June 17, 2023 I tested both CreateCheckBox2 and CreateRadioButton2 and could not for the life of me get it to add an image to the checkbox or radio button, I get the exact same result as @twk. I should note that I am on Windows and using Vectorscript rather than Python. I used an Image Push Button as something of a control, and had no problem getting the image to work when using the VW resource path. However, I could not get it to work with an exterior image file, no matter how I wrote the path out (even used a similar method to what @Pat Stanford described above, put an icon .png into my User Folder and then used FindFileInPluginFolder to generate a path to the icon), I could not get it to populate on the push button, just got the red "x". The documentation is, as expected, very sparse, with no examples and the rather cryptic parameter description of: Quote The string identifier for the image. It should be of the form "ResourceFileNameWithoutExtension/PathOfImageFile" Any idea how to use custom images for buttons outside of the standard Vectorworks icons? Quote Link to comment
MullinRJ Posted June 17, 2023 Share Posted June 17, 2023 16 minutes ago, Jesse Cogswell said: Any idea how to use custom images for buttons outside of the standard Vectorworks icons? Hi @Jesse Cogswell, Place your images in a folder. Select the folder and ZIP the folder. With the resulting ZIP file, change the .zip extension to .vwr and you now have a VW Resource file. I believe the commands you referenced can use the path of the .vwr file as your path input. I haven't tried it, so please let me/us know how it turns out. Thanks, Raymond 1 Quote Link to comment
Jesse Cogswell Posted June 17, 2023 Share Posted June 17, 2023 Okay, it took a little bit of doing, but I got it to work. The main thing to remember is to restart Vectorworks after making any changes to the VWR so that it can be properly loaded. I did end up structuring my VWR file according to this page on the developer wiki with the embedded folders, and then it worked properly. There is a fantastic chance that you don't need the file structure and I just needed to restart VW. What also super great about this information is that I could reverse this trick to get a file of all of the standard VW icons by making a copy of the Vectorworks.vwr, changing the extension to .zip, and extracting the Standard Images folder. No more having to guess icon names until I land on the right on, so big thanks to @MullinRJ for the info. Sadly, still no luck on getting CreateCheckBox2 and CreateRadioButton2 to work, though. PROCEDURE ImageTest; CONST kTestPath = 'JNC Resources/Images/JNC Toolbox Icon@2x.png'; VAR dialog,layoutDialog:LONGINT; FUNCTION DrawDialog(DName:STRING) : LONGINT; VAR dia:LONGINT; str:STRING; BEGIN dia:=CreateLayout(DName,FALSE,'OK','Cancel'); CreateImagePushButton(dia,11,50,kTestPath); CreateCheckBox2(dia,21,'Check Box',kTestPath); CreateRadioButton2(dia,31,'Radio 1',kTestPath); CreateRadioButton2(dia,32,'Radio 2',kTestPath); SetFirstLayoutItem(dia,11); SetBelowItem(dia,11,21,0,0); SetBelowItem(dia,21,31,0,0); SetBelowItem(dia,31,32,0,0); DrawDialog:=dia; END; PROCEDURE DialogHandler(VAR item,data:LONGINT); BEGIN CASE item OF SetupDialogC: BEGIN END; 1: BEGIN END; 2: BEGIN END; END; END; BEGIN dialog:=DrawDialog('Test'); layoutDialog:=RunLayoutDialog(dialog,DialogHandler); END; Run(ImageTest); 1 Quote Link to comment
MullinRJ Posted June 17, 2023 Share Posted June 17, 2023 @Jesse Cogswell, I'm glad I could help, and I thank you for your "BIG thanks", but really?!?, no Simpson's Yellow Thumb of Approval, 👍? I'm never going to catch @Pat Stanford at this rate. ☹️ Raymond Quote Link to comment
twk Posted June 17, 2023 Author Share Posted June 17, 2023 4 hours ago, MullinRJ said: @tui_k, Using your code on a Mac I get : but I used: vs.CreateRadioButton2(dialog_id, 6, 'Push Button', layer_icon_path) instead of: vs.CreatePushButton(dialog_id, 6, 'Push Button') Perhaps it's a Mac/PC thing. I'll try on a PC, but it may take a while. Raymond Much appreciated @MullinRJ. So it looks like it is a windows issue. I've also wondered whether any of the native vectorworks tools implemented that checkbox/radio item image control. Thanks again I shall open a bug ticket for windows. Quote Link to comment
twk Posted June 17, 2023 Author Share Posted June 17, 2023 1 hour ago, Jesse Cogswell said: There is a fantastic chance that you don't need the file structure and I just needed to restart VW. My testings have shown you dont actually have to restart VW. You just need to open the Plugin Manager, navigate to your plugin/tool, then select "edit definition" or "edit script", then close it, then exit plugin manager. Quote Link to comment
Jesse Cogswell Posted June 17, 2023 Share Posted June 17, 2023 @twk that's probably very true, though I'm not sure about document scripts, which is what I was using to test this. That's the problem with changing multiple things between tests, you never know which thing you changed actually created the fix. @MullinRJ D'oh! Slipped my mind, thank you for keeping me honest. 1 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.