Jump to content

Delete 3D of symbol

Recommended Posts

Hello @sandertb,

   You can get into a symbol definition with H = Fin3D(GetObject("SymDefName")) which will give you a handle to the first object in a named symbol definition. Then step through the object list with H = vs.NextObj(H) and test each object's 3D-ness with:    


H = vs.FSActLayer()
is3D = vs.GetObjectVariableBoolean(H, 650)    # 3D


   You may have to make a decision how to treat Layer Plane objects and 3D Plane (2D Planar) objects. Technically, Layer Plane objects which look like 2D objects, are considered 3D by the ObjVar_650 test, as are 2D Planar objects.


# This will keep Screen & Layer Plane (Symbol Definition Plane) objects, and exclude "classic" 3D objects (Extrudes, Sweeps, 3D Lock, 3D Polys, Solids, etc.)

H = vs.FSActLayer()
is3D = vs.GetObjectVariableBoolean(H, 650) and not vs.GetObjectVariableBoolean(H, 1161)    # 3D and not Planar


Use ObjVars:

   651 for 2D;

   650 for 3D;

   1160 for Screen Plane;

   1161 for Planar;

   1162 for Layer Plane

testing. You may have to craft the logic that filters out exactly what you don't want. 


   When you decide to delete an object, make sure you get your next object handle FIRST, before you delete anything.


   Additionally, you can use ForEachObjectInList() to step through a symbol's elements, but that tutorial is longer.





PS - There are no simple questions, and fewer simple answers.


  • Like 1
Link to comment

OK, this is weird. When I wrote the above, I was testing objects on a Design Layer. I just now tested the same objects inside a Symbol Definition.


A Layer Plane Object inside a SymDef shows in the OIP as being on the Symbol Definition plane. It displays on the 3D side of the symbol. It tests as 3D, but does not test as Layer Plane. On a Design Layer, the same object will test as 3D, AND as Layer Plane.


Bottom Line : Test you code very carefully.



  • Like 1
Link to comment

The way I've done this is by testing object variable 1160 for screen plane.  For hybrid symbols, the screen plane is what is used to differentiate between a 3D component and a 2D component (one of the reasons that removing the screen plane in 2022 made creating a hybrid symbol out of an already existing 3D symbol much more difficult).


So I would go about doing this by using vs.FInGroup() on the symbol definition and stepping through with vs.NextObj() while doing a check with vs.GetObjectVariableBoolean([handle],1160).  The kind of tricky thing is that you can't just use vs.DelObject() to delete the object right away, otherwise you can't use vs.NextObj() properly.  So you instead have to copy the handle, use vs.NextObj(), then delete the object.


My Python is a little rusty, but I just tested the following Vectorscript in 2022 and it worked well, even with Legacy 2D Features disabled.  Searching for Screen Plane works best because then even traditionally 2D elements (such as text) can be removed from the 3D component of a hybrid symbol.




	kSymbolName = 'Test Symbol';



			IF(GetObjectVariableBoolean(h,1160)=FALSE) THEN
			ELSE h:=NextObj(h);



Link to comment

Thanks so much @MullinRJ @Jesse Cogswell, you gave me a lot more info then expected.
I'm testing the first version in Python as we speak, and it seems to work great so far!

Me and my colleagues will never have to remove our custom 3d symbol components by hand anymore when we need to share a file. This is gonna save loads and loads and loads of time, I can't thank you enough!

Link to comment
  • 2 months later...


Hi guys,

I've run into an issue where symbols that themselves consist of multiple symbols and/or locus points are not converted properly to a 2d symbol.
I've tried converting these symbols into groups, and then calling the delete3d function again, but this does not seem to work as expected.

h1 = vs.FInGroup(symbol)
    while h1 != None:
        if vs.GetObjectVariableBoolean(h1,1160) == False:
            h2 = h1
            h1 = vs.NextObj(h1)
            sType = vs.GetTypeN(h2)
            isSymbol = sType == 15 or sType == 16 or sType == 11 or sType == 86


            if isSymbol:
                prevObj = vs.PrevObj(h2)
                vs.SymbolToGroup(h2, 1)
                toMessage.append("symbol to group" + "\n")

            h1 = vs.NextObj(h1)h1 = vs.FInGroup(symbol)


Does anybody have a clue what I should do differently?

Link to comment
  • 1 month later...

Could you not just collect all object handles into a python list. then delete after collection?


(I've left out the convert nested symbols code). Hopefully the cleaner python will send you on the right track.)

import vs

def delete_3D_objects_in_symbol(symbol):
    _3D_components_in_symbol = []
    h1 = vs.FInGroup(symbol)
    while h1 not in [0, None]:
        if not vs.GetObjectVariableBoolean(h1, 1160): # Not Screen Plane Object
            sType = vs.GetTypeN(h1)
            isSymbol = sType in [15,16,11,86]
            # if isSymbol:
            #     prevObj = vs.PrevObj(h2)
            #     vs.SymbolToGroup(h2, 1)
            #     toMessage.append("symbol to group" + "\n")
            #     delete3dGeometry(vs.NextObj(prevObj))

        h1 = vs.NextObj(h1)
    for obj in _3D_components_in_symbol:


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.

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