Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  
GioPet

Copy/Paste Objects and Reassign Incoming Classes to Existing Classes

Recommended Posts

Hi Gio,

It works now! :-)

I added a one-liner subprocedure and a ForEachObject statement in place of:

NameClass(LOC_ClassArray[x]);

SetClassOptions(1);

SelectAll;

SetClass(h,assign_to);

This method should be much faster and also will look inside symbols and groups.

http://pastebin.com/m53c80150

Share this post


Link to post

aha..:)

I had just edited the previous post..

in the meantime I worked out this

ForEachObject(AssignThem, SEL);

SEL criteria did the job, when calling the procedure

PROCEDURE AssignThem(h :HANDLE);

BEGIN

IF GetClass(h) = LOC_ClassArray[x] THEN SetClass(h, assign_to);

END;

thanks anyway!

Share this post


Link to post

You're welcome.

You did almost exactly what I did! :-)

I'd still recommend my version since it doesn't change the active class or selection state of any objects. This should make it run faster and leave the drawing state as the user would expect. Plus it should work on objects within symbols and groups.

If you have a large file to test on, try both versions to see if there's a difference.

Share this post


Link to post

Thanks Matt, i will test what you said sometimes next week, and still need to work on the Undo Button!!

Now, here is a Cleaner version..

.vsm File or http://pastebin.com/m67ebd879

I got rid of some local and Global variables that were flying around without being very useful..

have a good weekend

G

Share this post


Link to post

Glad to help Gio.

You have a good weekend as well. I plan to make mine restful. I've shoveled far too much snow this week...

Share this post


Link to post

Ciao Giovanni,

did you consider building the LB on resource lists passing obj type 94?

Using the resource lists you are also able to offer the choice of items residing in the standards folder, moreover the list is automatically alpha-sorted, which is good.

i := 0;

WHILE GetNumLBItems(gD, cLB_Left) < gNumClasses DO BEGIN

clN := GetActualNameFromResourceList(gClassList, inc(i));

.....

I can't try the script now, but it looks nice!

orso

Share this post


Link to post

Ciao Orso!

thanks for the suggestion. I hadn't thought about passing obj type 94, it actually sounds a much more straight forward way to build the resource list.

I will go through the script again, hopefully soon..

If anyone who has tried the plug in had other suggestions, please let us know!

Bis Bald

G

Share this post


Link to post

Hello Everyone!

Here is a new Downloadable Script for the Smart Paste!

Download both attachments (_DialogBuilderUtilities.txt is needed too)

or

View the Script Here

http://pastebin.com/18FHi3iv

I have Re-written the Script using Resource Lists to Build the List Browsers as suggested by Orso.

This worked Smoothly (thanks orso).

I also worked out the Undo Button. I had to use arrays because I faced some problems in outputting the User selections to a txt file and then reading them back to Undo the Actions.

If anyone can give me some hints on this, it would be good..

I still have the intention to implement the functionality of saving the User's Choices so that the plug in will be able to do part of the Job automatically, without the User to always re-select already made associations (Matt, I think you suggested this at some point..)

Many Thanks to everyone for helping out with this so far!!!

Gio

PS: this script has only been tested on a Mac version of Vectoworks 2009. Please let me know anyone experiences problems with other versions.

Edited by Gio Pet

Share this post


Link to post

Hi Gio,

It would be good if the dialog box can show which existing class has been assign to incoming class after click the Assign button. for large copy element which consist of a lot of classes, it is good if we can do a final checking ( correct assign ) before we proceed to OK button. for large project, it is very difficult to correct it if we assign wrongly. Once the new paste element has been park under current existing class which consist thousand of objects. it will be though to fix it.

btw. it is nice script. credit to you.

G-Pang

Share this post


Link to post

G-Pang, Great suggestion!

I will implement this and post it as soon as it's done.

Thanks

G

Share this post


Link to post

I finally got a chance to look at this.

Well done Giovanni! I've not played around with resizable dialog, but I'm sure you're aware of the LB widths not sizing correctly.

This will be a good command to have on hand. Keep us posted on any updates. :-)

Share this post


Link to post

If you want to load use an external file use the XML functions.

Here is a snippet to get started.

When you script is executed you will want to write to the XML file

what the old class was and what the new class is

When you load your script you will want to load the XML file and see if there are any classes to be reassigned with defaults if so set the default.

___________________

PROCEDURE GetXML;

CONST

kLibraryFolder =-13; {constant to set the file path to the VW library folder}

VAR

hXML :LONGINT;

xmlFile :STRING;

result :INTEGER;

BEGIN;

hXML := InitXML;

IF hXML <> 0 THEN BEGIN

xmlFile := 'ClassAssign.xml';

result := ReadXMLFile(hXML, kLibraryFolder, xmlFile);

DATAPath:=Concat('/Prefs/',ClassName[]); {defines the classname path, upto you how to this is structured.}

result := GetElementValue(hXML, DATAPath, NewClassName[]));

{this will return the value to NewClassName[]}

result := ReleaseXML(hXML);

END ELSE BEGIN

SysBeep;

Message('Could not initialize XML reader.');

END;

END;

Edited by Assembly

Share this post


Link to post

Hello Everyone!

Great Inputs guys!!

Assembly, this is great, exactly what I needed..

hopefully will not take to long before the next update!

G

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×