Jump to content
Developer Wiki and Function Reference Links ×

Change default PIO parameters from script.


Recommended Posts

The default values of the parameters of a PIO are defined by the plug-ins editor.

The first time the PIO is used in an file, we get the opportunity to set other values ( Object Properties dialog).

If the same files is used as template, the Object Properties dialog will not appear at the first use of the PIO because the default value are stored in the template.

We can still change those values by clicking on the Object Properties button of the PIO.

So far, everything is OK.

Now here is my questions :

Can we change those values from script ?

I actually would want the users of my plug-ins to be able to set different defaults to draw different type of things within the same template.

Link to comment

Yes. Basically, getting a handle to an object with the name of your PIO will let you access document defaults. Something like this:

recHan:=GetObject(kObjectName);

IF recHan=NIL THEN BEGIN
tmpHan:=CreateCustomObjectN(kObjectName, 0, 0, 0, FALSE);
DelObject(tmpHan);
recHan:=GetObject(kObjectName);
END;

In the second part, if the the PIO has not yet been placed in the document, I add an instance, then delete it, which reates the defaults record.

-Josh

Link to comment
  • 1 year later...

Ok, that works great.

But I now need to access real default parameters of my PIO's. The ones set is the Plug-in editor not the ones stored in the VW file.

I could erase the PIO record definition (Delobject(GetObject(kObjectName))

and create a new one

tmpHan:=CreateCustomObjectN(kObjectName, 0, 0, 0, FALSE);

DelObject(tmpHan);

But then, all the PIO's present on the drawing become useless (Broken)

You have another way?

Link to comment
Ok, that works great.

But I now need to access real default parameters of my PIO's. The ones set is the Plug-in editor not the ones stored in the VW file.

I could erase the PIO record definition (Delobject(GetObject(kObjectName))

and create a new one

tmpHan:=CreateCustomObjectN(kObjectName, 0, 0, 0, FALSE);

DelObject(tmpHan);

But then, all the PIO's present on the drawing become useless (Broken)

You have another way?

You could store default values in another file? Or you could save these values in the strings of the plug-in or in your script as constants, because why would you want the defaults you set in the plug-in editor as the user can also change this? I think there is a better solution for what you are trying to do.

Link to comment
  • Vectorworks, Inc Employee

I'm a little confused about exactly what you are trying to accomplish.

The default values for a PIO should be created as reasonable defaults that work when the PIO is first placed.

If you need to set document level defaults then you have a method to access the default record in the document and save document settings.

If you want to set machine/user defaults I recommend using Set/GetSavedSetting(). This will save and recall the settings from the user xml file. I would then copy the settings to the document default record. If the user resets their user preferences the xml file will be cleared so the user can easily go back to the PIO defaults in a new document.

GetSavedSetting will return False if the setting is not found so you can handle it appropriately.

If you are trying to make default values conditional on other parameters then you need to store this information somewhere. Either in additional record formats or additional parameters of the object and handle the custom defaults using code during the preference event for the object.

Link to comment

I have a new version of my PIO's and some default parameters have changed.

The default parameters are set in the template my users use.

So with the update of the plug-ins I am going to distribute a new template.

The problem is that some older files might produce weird results with the new plug-ins.

So I'm thinking of doing an update script to set the new default in older files.

I could 'hard code' the default in my script, but I would prefer to be able to read the real default parameters. (the ones set in the plug-ins editor, not the default in the current file.)

Link to comment

Then you will need to save these different default values somehow. You can use a file or a record, ....

I think that would be the best ways if a direct access in not possible.

Exporting default values from one up to date file then importing them in the out of date file...

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