Jump to content

CreateRadioButton2 and CreateCheckBox2 functions not working


Recommended Posts

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)

 

image.png.d8de144e690d5115e2814fe24ae662e5.png

Link to comment

@tui_k,

   Using your code on a Mac I get :

 

image.png.a3071c3ddf7edc639075aa4429726b3b.png

 

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

 

 

  • Like 1
Link to comment

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

Link to comment

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?

Link to comment
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

  • Like 1
Link to comment

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.

 

image.png.6ee7d16bc9e081b0e12283a6ba578545.png

 

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);

 

  • Like 1
Link to comment
4 hours ago, MullinRJ said:

@tui_k,

   Using your code on a Mac I get :

 

image.png.a3071c3ddf7edc639075aa4429726b3b.png

 

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.

Link to comment
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.

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...