Jump to content
Developer Wiki and Function Reference Links ×

One parameter to contol two different plugin objects?


Recommended Posts

Anyone know a way to create two different plugin objects that utilize a common parameter?

I want to be able to create an object (objectA) and another object (objectB). I need a way to link objectA and objectB together. Once they are linked I would like them to be able to utilize a common parameter, such as, the object width.

This way if I change the width of objectA the width of objectB changes as well.

Any ideas?

Thanks in Advance

Derek

Link to comment

DWorks,

but how would I go about referencing an outside plugin object in my script? Is there a way to give the plugin object a name once it is created?

I have a plugin object that creates a window in plan. I also have a plugin object that creates a window in elevation. I want to be able to change the width of the window in plan and have it also change the width of the window in elevation. and vice versa. This means I need to be able to create each object seperately and then i need to be able to link the two (using a parameter or a name) is it possible or is there a better way to do this?

Link to comment

To expand on Dieter logic, you need to compare previous with current width to reset the other object and prevent it from looping back and forth.

IF prevWdt <> currWdt THEN

BEGIN

SetRField(obj2Hdl,obj2Name,obj2FieldPrev,Num2Str(4,currWdt));

SetRField(obj2Hdl,obj2Name,obj2FieldCurr,Num2Str(4,currWdt));

ResetObject(obj2Hdl);

END;

If the updating is only one-way then you only need to set the new width on the other object

SetRField(obj2Hdl,obj2Name,obj2FieldCurr,Num2Str(4,currWdt));

ResetObject(obj2Hdl);

Link to comment

You need to assign a unique ID for both objects. If you assign the UID to the object's name, it is easy to retrieve a handle using GetObject

You would store the UIDs of the linked objects in something like a 'link to' parameter, which you probably want to lock or hide.

You can use object event handling to know when a specific parameter has changed. If so, you would use setRField to copy the dimensions to the other object.

You would also set something like a fromLink Boolean field to true in the linked object. So:

If fromLink set fromLink param false else updateLinkedObject;

That would prevent a loop of the objects updating each other..

-Josh

Link to comment

ok so here you are saying I need to have a record created. I store the width in one of the record fields. The objects reference the record to obtain the width. when I change the width of objectA it changes the width of the field in the record therefore changing the width of objectB?

Next question, how do i create the record? and how do I get both objects to reference the same record?

Link to comment

Next question, how do i create the record? and how do I get both objects to reference the same record?

All pio's already have a record with the same name as the pio. You only need to add a hidden parameter to the pio's list.

The alternative method as discussed before, which is more complicated, is to use the event handling feature where VS tells you which parameter has changed.

Link to comment
DWorks,

but how would I go about referencing an outside plugin object in my script? Is there a way to give the plugin object a name once it is created?

I have a plugin object that creates a window in plan. I also have a plugin object that creates a window in elevation. I want to be able to change the width of the window in plan and have it also change the width of the window in elevation. and vice versa. This means I need to be able to create each object seperately and then i need to be able to link the two (using a parameter or a name) is it possible or is there a better way to do this?

You can let VS search for the object by plugin name and check for a field value, like a window id. This way, you can have more than two objects linked, like when you have multiple windows that are the same.

Link to comment

Is the name used in the script the same name i give the plugin in the VectorScript Plug-in Editor?

If so, how do i differentiate between 2 different objects create with the same plugin tool.

Example: I create one window in plan using the plugin. Its with will be 24". I then create a window in elevation that is linked to the window in plan. Its with is 24". I now want to create a new window in plan that will be 36". Will there be issues with the width if I create this new 36" window?

Sorry if I'm confusing you folks. I am always trying to work these things out on my own and appreciate the help.

Thanks

Derek

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