Jump to content
Developer Wiki and Function Reference Links ×

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

@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 2
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
  • 5 months later...

Hi @Jesse Cogswell we are now in the progress of modeling an existing highly modular building. You plugin is a real timesaver! Thanks again! A college noticed a hybrid 2d/3d within a symbol cannot be made unique when in 3D edit mode. Making the symbol unique in 2D edit mode works correctly. But sometimes it's more difficult to select the object in 2D mode. Being able to make the symbol unique in 3D mode would be great. Can your take a look, perhaps it's a small fix? See screenshot and file below.

 

Best wishes for 2022!

Error plugin.JPG

Error plugin.vwx

Link to comment

@MarcelP102 It took me a bit to figure out what was causing the bug, but it was really easy to fix once I found it.  The script works by building a "blank" symbol definition using a locus point, then copying all of the components from the original symbol into the new symbol definition, then finally deleting the locus point.  It breaks when the script is run inside a symbol, as the locus point is created in the 2D component of the symbol, so the new symbol definition doesn't actually get created.  The fixed script will now pull your current view projection and create a 2D locus if in Top/Plan view or a 3D locus if you're in a 3D view.  I did some tests and couldn't make it break, so you should be good to go.

 

Happy holidays!

Make Symbol Unique.zip

  • Like 2
Link to comment
  • 3 weeks later...

Hi Jesse, can confirm it is working as expected. Thanks! 

 

Ps. Would it be an idea to start an github/gitlab account where you collect your plugins? That would make the discovering of your plugins better and gives us the possibility to share translated versions of you plugins. You can then simply link to the plugin instead of uploading it to all the different forum topics. 

Link to comment
  • 6 months later...

Hi @Jesse Cogswell

 

I found two bugs while working with 3D symbols.

 

1. When making the bars unique some bars gets duplicated. Sometimes even multiple times. See screenshots and attached file.

 

Before

1575020112_Makeunique-duplicatesbefore.thumb.JPG.3972592905071d965f38c5e98d36f7f2.JPG

 

After

950163846_Makeunique-duplicatesafter.thumb.JPG.06d0087bc30a7bcd26a17dac5e71e38a.JPG

 

2. When making this symbol unique the mirrored symbols gets flipped. See screenshots and attached file.

 

Before /after

1247319502_Makeunique-mirror.thumb.JPG.778318e777b3b607159a6cb78192047a.JPG

Make unique - duplicates.vwx Make unique - mirrored objects.vwx

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