Jump to content
Developer Wiki and Function Reference Links ×

importing symbols into scripts?


markj

Recommended Posts

I have created some simple scripts which will draw various objects, I now want to be able to add a symbol to the object.

I need to be able to do this via the oject info box, which I presume will be set up with the parameters menu. The aim is to allow me to choose one symbol from a pop-up list of several.

My problem is, is how to reference all the bits together. What variables do I need to decalare?

Am I right in thinking that I need to use an "IF THEN ELSE" procedure to allow me to choose which particular symbol I will use from the pop-up list.

Incidentally, the most useful publication I have found so far has been the Minipascal manual from V6 minicad. - Surely there is an opening here for a simply written Vectorscript primer, with loads examples to modify. Vectorworks is a breeze to use, and the ability to create custom scripts/tools etc. makes it very useful. Unfortunately we are not all computer programmers, so sussing this bit out is a bit of an uphill struggle!

Anyway, any help on how to achieve the above would be gratefully appreciated.

Thanks

Mark

Link to comment

I've never actually used one, but all you need is a parameter field of type 'Popup'. No need for ifthen logic.

To get an idea how it might work try what I just did. Go to plugin editor and create a new PIO object, probably point type. Don't worry bout having a working script for it. Hit the parameter button, then 'add', give the field a name, and from 'Type' choose pop-up. Make a list of choices and hit done. Add this empty PIO to your workspace and try placing it. You now have a PIO that does nothing, but does show you how the field will work.

You would get the choice into your script with something like Symbol(PNAME,Px,Py,Angle) where NAME is the name you gave to the field above. The P in front is a vectorscript convention for getting info from parameter fields.

In your working PIO you will have to assign choices to the popup parameter that are literal. IE if the choice name is in anyway different than the actual symbol name, your PIO will not place a symbol. But I think this is the only way you'll be able to make and change symbols with Object Info. As far as I know there's no way to change a parameter name from within a script...that's where the 'style-1,style-2' thing in the stock PIO's comes from.

If up to this point you haven't run your scripts as actual PIO's but from a script palette or as a menu command, you'll need to read up on them in the v-scrpt language guide to learn more. I'd say it's actually easier than creating a dialogue with choice lists in the way you might be thinking of now.

Hope it's helpful

Charles

Link to comment

Hi Charles,

Thanks for the help - well, it sort of works.....sort of, sometimes.

The script doesn't always run every time from the tool pallette where I have put it. When it does the symbol appears as required, but the object info doesn't always show the pop-up selection box. When it does, changing the pop-up selection to a different symbol, doesn't affect the instance on screen, although I can redraw it with the alternative symbol in place.

I am not exactly sure where the trouble lies, but it is veery satisfying to click the check script button & see 'script compiled successfully' come up - so I must be making some headway!

Mark

Link to comment

Sort of works sometimes sorta means that somethings wrong somewhere. Pretty much impossible to guess what it might be.If you want to post some code we might be able to help.

If it's huge you might start with the area of the code that places the symbol, including how you're setting the insertion point.Also confirm what kind of PIO this is...point object perhaps?

When you say it doesn't always run, you mean you don't get an insertion cursor? I can't think of why your PIO isn't always behaving as one. The flakiness makes it harder to figure.

A good way to trouble-shoot something like this is to simplify your script in ways that isolate the problem. Try enclosing complete sections with {} to make them invisible to the compiler. In particular the area that places the symbol.If you now consistently get the rest of your PIO to draw itself (without the symbols of course) and with the OIP behaving as it should, then you've started to isolate the problem. If not, it's probably somewhere else.

It probably is somewhere else since you have a script that compiles. Maybe something about the name of the pop-up or the names of the symbol? (drawing at straws.)

c.

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