Jump to content
Developer Wiki and Function Reference Links ×

Change tool behaviour with mode bar.


Letti R

Recommended Posts

Hello,

 

i want my tool to change the action that is needed to run, based on the mode that is selected in the mode bar. Unfortunately i cant find a fitting example, or i am overlooking it.

 

The tool should behave like this:

- First mode -> Run the tool after clicking on the drawing

- Second mode -> Run the tool after clicking in 3d and catching the 3d point

- Third mode -> Run the tool after drawing a line in 3d and catching start and end point

 

How can i do this? I hope someone can point me in the right direction.

(Sidenote: I am new to working with the SDK and new to writing in C++)

 

Regards,

 

Letti

Link to comment

This is not that easy, the most difficult part is overwriting the default behaviour in VWToolDefaultPoint_EventSink::HandleComplete(). This means you need to cover all the cases yourself. I had to do it too for one of our tools to go from a point mode to a line mode. However, if the object should not be inserted into a wall, it will make things a lot easier.

 

Anyway, these functions need to be adjusted:

VWToolDefaultPoint_EventSink::Init()
	SDefaultPointToolInfo	toolInfo = this->GetToolInfo();
// Set the mode groups
	this->SetToolInfo( toolInfo );


VWToolDefaultPoint_EventSink::DoSetUp()
// Set all the button images

VWToolDefaultPoint_EventSink::GetStatus()
	IToolStatusProvider::GetTwoPointToolStatus() etc

VWToolDefaultPoint_EventSink::DoModeEvent
// When user clicks Mode Bar.
	

VWToolDefaultPoint_EventSink::PointAdded()
	VWToolDefaultPoint_EventSink::PointAdded();	// Needs to be called when the last click is done (depending on your mode)
	// You can get the num of clicks that already happened with:
	this->GetToolPointsCount();

VWToolDefaultPoint_EventSink::HandleComplete()

 

I think this is the minimum of functions you need to implement.

  • Like 1
Link to comment
  • 4 weeks later...

Hello,

 

i just "finished" the first verion of my tool and when i compile it for windows everything works just fine. But when i compile the tool for macOS, the images in the mode bar (only in the mode bar) are missing (it shows an image of a red "x" instead of my image).

 

Could this be because of the resolution of the mac i was testing on (4k)? And how do i add the "2x" images for the screens with high resolution?

 

Also i think i did not set up or install the SDK on the mac correctly. Unfortunately i am not familiar in working with a mac. Is there a recent, easy to follow guide about how to setup the SDK and xcode?

 

Regards,

Letti

Link to comment

For the images on mac, you need to ad "@2x" to the image name, and that icon needs to be double the size of the normal image. So:

 

YourToolName.vwr/Images/imageName.png

YourToolName.vwr/Images/imageName@2x.png

 

About setting up the mac, I can't help much because I struggle with that too 🙂 .

Link to comment

Hello,

 

thanks for your reply.

Im sorry for not pointing out that i already set up my images like that, but it still does not work.

 

MyTool.vwr/Images/MyImage.png (26x20 pixel, 72dpi)

MyTool.vwr/Images/MyImage@2x.png (52x40 pixel, 144dpi)

 

And in the .cpp file i wrote it like this:

TXStringArray imageSpecs;
imageSpecs.Append("MyTool/Images/MyImage");

 

Is that enough or do i have to do something like:

 

if operating system is mac

    imageSpecs.Append("MyTool/Images/MyImage@2x");

 

Unfortunately i cant just try it, because i dont have access to a mac right now.

 

Regards,

Letti

Link to comment
10 hours ago, Letti R said:

And in the .cpp file i wrote it like this:

TXStringArray imageSpecs;
imageSpecs.Append("MyTool/Images/MyImage");

 

 

In our code, we've added the .png extention, maybe that's the reason it doesn't work in your end?

 

TXStringArray imageSpecs;
imageSpecs.Append("MyTool/Images/MyImage.png");

 

  • Like 1
Link to comment
1 hour ago, MullinRJ said:

Have you tried saving your 2x image at 72 dpi? I have a very old memory whispering that it may be relevant. It’s an OLD memory so let me know if it is relevant. 

The png's inside the Vectorworks.vwr file are also 72 and 144 dpi, and in our tools too, so that should not be an issue.

Link to comment

Hello,

 

On 6/25/2022 at 7:33 PM, Maarten DE said:

In our code, we've added the .png extention, maybe that's the reason it doesn't work in your end?

 

This was the solution. Now the Images are also shown on a mac.

Thanks alot for the help.

 

Regards,

Letti

  • Like 1
Link to comment
  • 5 months later...

Hello,

 

i compiled my tool with the 2023 SDK without changing anything in the code (the tool works without any problems in VW 2022). The compilation ends without an error, but when i tried to run the tool, VW crashed.

My VW version ist 2023 SP1, and the SDK version is VW28.0.0.

I think the crash occurs when tool points are cleared, but im not sure.

 

I can get rid of crashing VW by using "VWToolDefaultLine_EventSink" instead of "VWToolDefault_EventSink", but than i dont know how to remove the 3 standard buttons in the mode bar grafik.png.34fc5119fab082bf754be230bc079d28.png.

 

Also i noticed that everytime i crash VW a crash dump file gets created, is there a way to open these files and get meaningful information from them? And how do i find out what exactly causes VW to crash?

Or would it be better to remove the standard buttons that come with "VWToolDefaultLine_EventSink"?

 

 

Regards,

Letti

Link to comment
  • 10 months later...
  • Vectorworks, Inc Employee
15 hours ago, Letti R said:

so i finished my Plug-in. Now i want to put it in the Forums to share it (for free). Is there something i have to consider to not run into legal problems because i used the VW SDK, or can i just put it out there for others to use?

@Letti R we have nowadays the Partner Install feature, that allows users to install/add on features developed by third-parties. Send me an email to vstanev@vectorworks.net and I'll forward it to the correct people for that.

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