Jump to content
Developer Wiki and Function Reference Links ×

Disable/Enable 'Create New Class' Function


GioPet

Recommended Posts

Hi,

I am working on a plug-in to "lock" the drawing class structure, in order to control the automatic creation of new classes when Copy/Pasting from other drawings.

At the moment I am wondering if there is a way to Enable/Disable the NameClass Function with a VectorScript or whether it has to be implemented via SDK.

This would help a lot the workflow of certain projects we have at my office, Therefore any suggestion will be very appreciated.

Thanks

Link to comment
  • Vectorworks, Inc Employee

Hello Gio Pet,

I don't think there's any way to disable the making of new classes. If this is solely to prevent creation of new classes when pasting objects maybe you could create a replacement Paste menu command. This command could:

1. count and store all existing class names in an array.

2. paste the objects

3. count the number of classes again

4. If the number of classes changed, then:

compare all current document class names with those in the array

When any are not found in the array, prompt the user to remap the class to one from the array.

Just a thought...

Link to comment

Thanks Matt! Precious hint..

The creation of new classes when pasting is the main concern indeed.

Yet I would like to find a way to obfuscate the command to create of new classes too..

However, I will follow your advice and develop the Paste command as you suggested.

Link to comment
  • Vectorworks, Inc Employee

You're welcome.

You could also create another command that compares all classes to a standard class list. If any extra classes are present, it could prompt the user to reassign. These scripts should be fairly easy to write. You will need to keep the original "Paste" command in your workspace (because the new paste script will need to call it), but you can name your command something like "Paste Safe" and change the "Paste" key command from "Paste" to it. You may also want to create a "Paste In Place Safe" command as well...

Good luck!

Link to comment
  • Vectorworks, Inc Employee

You're welcome G and great to hear it's coming along.

An interesting addition to the Paste scripts could be an option to save the mapping of the pasted objects so that the next time objects of the same class are pasted, it could either remap them automatically or have the dialog set the default mapping (to the last one used) when prompting the user. Just a thought... Maybe for version 2.0? ;-)

Link to comment

:) yeh, the version 2.0 will be great..

Though I am already thinking to make a 1.5 version too!!

At the moment the script Assigns and Deletes one by one the Newly pasted Classes, until they are all Reassigned and Deleted...

I know, it is not a very flexible behaviour..

(but this seems to be due to my scripting skills..)

So, version 1.5 will probably allow to deal with all the new classes in one window, and also will include a 'Non delete' Option!

then.. i will challenge 2.0!!

Link to comment

..Small question..

the beta version of the script is not behaving very well..

I have created 3 dynamic arrays (Existing Classes, Classes after Pasting, New Classes Only), then I populated them.

In this process i haven't sorted the Arrays. Can this be a problem?

It seems to me that VectorWorks assings ClassLIst value to New classes following the order of creation..

that's why I thought that sorting the arrays wasn't necessary

(the newly pasted classes would be added at the end of the array).

Does this make sense?

G

Link to comment

hi Mat,Here I am again.

I just fixed the Bad Behaviour (the array containing the extra classes only was populated with a wrong calculation..)

I have gone through the script again and step by step verified the content of all the arrays that i have populated (classes before pasting, after pasting, and only the extra classes).

It seems that VectorScript cannot manipulate Arrays of strings so that an operation like Arr3= (Arr2-Arr1) doesn't work to obtain the third Array (containing the newly pasted classes only).

For this reason I didn't sort the classes, but reasoned this way:

Defined two Variables

diff:=NewCLASSNUM - OldCLASSNUM;

StartClass:=(NewCLASSNUM - diff)+1;

the VAR diff gives the number of new classes being pasted, the StartClass gives the ID of the first New class. All the other new classes will have ID growing from StartClass up to NewCLASSNUM.

So I Populated the 3rd Array with this:

y:=1;

FOR x:=(StartClass) TO (NewcountClasses) DO BEGIN

IF y<=diff THEN BEGIN

ExtraClassNames[y] := NewClassNames[x];

y:=y+1;

END;

END;

Now I have all the ingredients.

I hope this still makes sense to you.

I will post the full script of these procedures in a few hours. Then i will start working on the interface of the menu..

laters.

G

Link to comment

Here is a link to the script i have written so far:

http://pastebin.com/m5287bf89

it can be copied and pasted directly into VectorScript Editor inside Vectorworks.

This script executes the command paste and prompt a dialog window to Assign ONE of the new classes to one of the existing, then deletes it.

Now I would like to create a Loop to keep prompting the dialog Window until all new classes are assigned.

Is there a way to retrieve the index of an Array of strings, given its string?

G

Edited by Gio Pet
Link to comment
Is there a way to retrieve the index of an Array of strings, given its string?

I think you'll have to do it 'manually'. I've never needed to do exactly this, but I would try stepping thru the array with a while loop with something along these lines:

index:=1;

stringMatch;=False;

While NOT stringMatch Do

????IF array[index] = theString THEN StringMatch := TRUE

????ELSE index:= index+1;

Message(index); {if you'd like to check}

The loop will terminate when it finds a match, and index should be what you're looking for. (or it might be index-1...)

If there isn't a match you'll have some trouble, so you better have a limiter in there like:

While (index < arrayLimit) & (NOT stringMatch) DO

??etc.

Since your using dynArray you've already calculated the array size, so you could probably just use that variable in place of arrayLimit.

Link to comment

THanks Charles, that does what I needed!

However, now I have problem with the Re-Allocation of DYNARRAYS of Strings..

(i thought it would work to clear an index and then RE-Allocate it and RE-Populate it, but I haven't been able to..)

I have now created a New POst in order to address better the intention of the Script I want to develop.

PLease, continue this Thread in the Topic

Copy/Paste Objects and Reassign Incoming Classes to Existing Classes

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