Jump to content

Request: Make 2d/3D Symbol 'Unique' script


Recommended Posts

As already discused here: https://forum.vectorworks.net/index.php?/topic/61717-make-symbols-unique/

it would be really usefull if there was a button/script that would duplicate a 2D/3D symbol and replace the selected symbol with the new duplicated 'unique' symbol.

 

- Can be a button in PIO, next to the 'replace' button

- And/or could be a item in the right-click menu, under the 'replace' option

 

Nice to have:

- pop-up that asks the name for the new symbol, by default add -1, -2 etc to the original name

- pop-up asking if you want all sub symbols to be unique

 

Starting point:

See https://forum.vectorworks.net/index.php?/topic/12522-duplicate-symbol-definition/&tab=comments#comment-396710

And https://gist.github.com/justinmilo/bbc1d64f28509737b601#file-makeunique-py

 

Unfortuantly this script can not duplicate  2D/3D hybrid symbols. But now it's 7 years later. Any possibility that VW script capability has grown so a true "make unique" script is possible?

 

I hope someone can help with this request. This would be super usefull during design studies where we often try out different options.

Edited by MarcelP102
Link to comment
Posted (edited)

@Jesse Cogswell I Have tried the script. It works perfectly for 2D symbols. But when I make a hybrid symbol containing walls unique I get this message see step 2. It's Dutch, but translates into 'Are you sure you want to degroup a object from a higher level?' The view is in 3D and showed the symbol 3x instead of 2x. 

 

When clicking YES: Results in a unique hybrid symbol but the walls are copied as polygone lines

When clicking NO: Results in correct unique hybrid symbol, without the extra polygone lines. But it has copied the walls outside the symbol

 

1- Start, 2x orignal symbol

1652754868_Step1.thumb.JPG.3dec49ec16f28eeae9759c9e9092b942.JPG

 

2- Pop-up

2144930774_Step2.thumb.JPG.942a715bef23e1bef7d34f2e39e57560.JPG

 

3 - Result of selecting YES

692530701_Step3-OptionYES.thumb.JPG.e9e5669c6b40c604b6f97cef179e016c.JPG

 

4 - Result of selecting NO

1716532111_Step3-OptionNO.thumb.JPG.66aedb90fab1862b063ce95946323529.JPG

Edited by MarcelP102
Link to comment

@MarcelP102
 The way the script works is that creates a new symbol with the unique name, drops the original symbol into the symbol definition, converts the symbol to a group, then ungroups the group to leave in the geometry.  For hybrid symbols, it does this twice, once for 2d geometry and once for 3d geometry.  My guess is that the error is a result of the walls essentially being dropped in twice, as they are hybrid objects themselves.

I'll look into this a bit more tomorrow, I might be able to fix it.  Until then, avoid using the tool on symbols containing hybrid plug-in objects (other hybrid symbols should be okay).

  • Like 1
Link to comment

@MarcelP102 Took another crack at the script, and I think I got it to work.  Let me know if you see anything else that isn't working as expected.  You should be able to do the same process using the Install button in the Plug-in Manager to install it as long as you haven't moved it around in your user folder (if so, delete the file from the user folder before installing).  No need to worry about editing your workspace again.

 

 

Make Symbol Unique.zip

Edited by Jesse Cogswell
Updated plug-in. Added functionality for mirrored symbols, layer elevations, and running on multiple instances of the same symbol at once.
Link to comment

Okay, so I started writing up a whole thing how none of the duplicate commands in the function reference apply to symbol definitions, as those were the things I tried first.  But in the process of writing that up, I got an idea to "crawl' through the selected symbol and use CreateDuplicateObject with each object in the symbol.  After some tricky coding to get those duplicated objects into the new symbol definition in the proper planes, I was able to make that work and without having to navigate around the quirks with the SymbolToGroup command and the problems it causes with high level objects.  The added benefit is that text objects linked to a record format now retain that link, meaning I was able to transfer records over as well, which was a huge downside to the original tool.

 

Big props to @Pat Stanford for making me get off my butt and work for it.  Updated tool attached.  Same installation as before.

 

EDIT:

Due to a request from another user, I've added the option to either retain the original symbol's records in the new symbol, or to overwrite the defaults with the symbol's current values.  It will prompt for each attached record, so you don't have to overwrite all of the record formats unless you want to.

 

 

 

Make Symbol Unique.zip

Edited by Jesse Cogswell
Updated plug-in. Added functionality for mirrored symbols, layer elevations, and running on multiple instances of the same symbol at once.
  • Like 1
Link to comment

CreateDuplicateObject should work for duplicating a symbol. The following is basically from my old archives of the Vectorscript Mail List (sadly defunct) from 2009. Thanks to @Julian Carr @Gerard Jonker and Bill Wood for this information.

 

Procedure DupeSymbol;
VAR
        h1 : HANDLE;
    s1 : STRING;
BEGIN
       s1 := GetSymName(FSActLayer);
   h1 := GetObject(s1);
    IF (h1 <> Nil) & (GetType(h1) = 16) THEN BEGIN
          h1 := CreateDuplicateObject(h1, GetParent(h1));
        SetName(h1, Concat(s1, '-1'));
  END;
END;
Run(DupeSymbol);

 

  • Like 1
Link to comment

After further testing, CreateDuplicateObject DOES INDEED work for duplicating symbol definitions, just not in Vectorworks 2019 where I was developing the original script.  I made a quick test file with the code Pat posted above, and it would not work in 2019 at all.  Opened the exact same file in 2021 and it worked just fine in duplicating symbol definitions.  I'm going to keep the original code as is to maintain backwards compatibility.

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