Jump to content

Custom Plug-In Question


Recommended Posts

I have a plug-in that calculates the number of pixels for a set of screens. 

 

I currently have to manually enter the pixel pitch and scale of in order to calculate the correct pixels dimension. 

 

What I would like to do, is have a way to "attach" the object to another object that I can then use to pull the pitch and scale data from. If either changed, then the pixel math would automatically change. I would be similar to how the dimensions feature works currently.

 

Is there a way to create a plug-in that is linked to an object.

 

Thanks

 

Martin

Link to comment

More info for a better answer please.  Is your plug-in just a calculation or is it an object that is placed in the drawing? How is the pitch and scale attached/entered for the other object? What makes entering the data there better than entering the data into your calculation PIO?

 

You should be able to make a link to another object, but it will depend somewhat on how much control you have other the objects.

 

Assuming you don't have control over the object that has the pixel information, I would consider adding a custom Record to that object and then storing a UUID into a field in that record. Store the same UUID into your calculation PIO to create the link and then figure out how to get the pixel information to transfer.  Probably need two modes to the calculation PIO, one to create the link and a second to update the calculation using the preset UUID information.

Link to comment

I have one plug-in that your enter the size, model, screen name and a few other details and it will draw a basic screen. This plug-in places symbols into the drawing. The symbols all have a specification record attached that contains the size in mm and the size in pixels. I enter the model from a dropdown on the plug-in, I then extract all the data from the specification record. This is called Create Screen.

 

The second plug-in is an attempt to replicate the dimensions tool. Currently I enter the model (same way as the Create Symbol), and a scale factor. With this data, I extract the size in mm and pixels and do the math for how many pixels wide/tall the screen is. This is called Create Pixels

 

What I would like is when I use Create Pixels I have way to select the screen it is being attached to (from the Create Screen) plugin, then extract the correct data with need to enter any data. When I run Create Pixels, I always am selecting a corner of the Create Screen object, is there a way to get and record the handle (is that the same as UUID?). I'm not sure how I would go about doing this.

 

The way I'm doing works, however if you have the wrong model or wrong scale, then the math is incorrect.

 

I am happy to send you a copy of the plugins, if that helps, however I would prefer to not publish to the forum. 

 

Link to comment

You should be able to do this with Associations:

 

VS:AddAssociation

VS:RemoveAssociation

VS:GetNumAssociations

VS:GetAssociation

 

Basically Associations create a link between two plug ins.  An association of kind 4 deletes the associated object when the master is deleted. Kind 5 resets the associated object when the master is deleted.

 

Your "dimension" PIO would be the associated object. You probably want to create at least a Kind 5 association and probably both (2 different associations). Then when the screen is reset, your dimension will be reset also.

 

In your reset code us GetAssociation to get a handle to the screen object and then do what you need to copy the data from there into the dimension object.

 

It will probably need some playing to get it to work, but  the online version of the function reference has a pretty good example of AddAssociation.  http://developer.vectorworks.net/index.php/VS:AddAssociation.

 

Ask again if you need more help.

Link to comment

Is your plug-in a Plug-in Object or a Menu command that presents a dialog?  It sounds like maybe the latter?  I would look into creating a plug-in object that draws the screen with all the various attributes as plug-in parameters.  You can then add a "Show Dimensions" checkbox that will draw the dimension lines for you, all as one object.

Link to comment

At the moment I am using a tool and not a menu.

 

You approach is interesting, however I have many different use cases that this approach would not work. The screen is often sliced in the raster to minimize processor. The pixel dimension is used in many places and not always attached to a single object. We often will have door or window cutouts that will also get a pixel dimension attached.

 

Thanks for the suggestion.

 

Martin

 

 

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