Jump to content
Developer Wiki and Function Reference Links ×

Create Symbol node

Recommended Posts

Hi everyone, I don't seem to be able to find a node that can create symbols. I did manage to find one that was written by domc, but it only creates a symbol in 3d space. Code is below.


Is there any way i can modify the configuration so that the objects being inserted go to 2d space, not 3d? I am trying to create a marionette program that creates symbols from groups - that have certain records. There has been other ones that have been done with creating symbol by object name (including groups) but it only works on single objects, groups do not show up in the 2d annotation space, thus disappearing


#DomC v001

class Params(metaclass = Marionette.OrderedClass):
    By = 'DomC';import datetime; now = datetime.datetime.now(); y80f5 = now.year;m80f5 = now.month; d80f5 = now.day; h180f5 = now.hour; mi180f5 = now.minute; s180f5 = now.second; ms180f5 = now.microsecond; h280f5 = h180f5-12 if h180f5 >=13 else h180f5; VersionChange1 = str(y80f5)+' '+str(m80f5)+' '+str(d80f5); VersionChange2 = str(y80f5)+'-'+str(m80f5)+'-'+str(d80f5)+'-'+str(h280f5)+'-'+str(mi180f5);
    TextStatic = Marionette.OIPControl( By +' v'+VersionChange2, Marionette.WidgetType.TextStatic, "")
    this = Marionette.Node( "Create Symbol" )
    this.SetDescription( 'Creates a new Symbol' )
    h_obj =  Marionette.PortIn(vs.Handle(0))
    h_obj.SetDescription( "symbol content (one object) if empty, an empty 3D (3D Locus) symbol will be created" )
    s_name = Marionette.PortIn('Symbol-1')
    s_name.SetDescription( "the symbol name" )
    s_sym = Marionette.PortOut()
    s_sym.SetDescription( "the result symbol name" )
    h_sym = Marionette.PortOut()
    h_sym.SetDescription( "handle to the newly created symbol" )

def RunNode(self):
    obj = self.Params.h_obj.value
    name = self.Params.s_name.value
    h = vs.LNewObj()
    h_sym = vs.GetObject(name)
    vs.SetParent(obj, h_sym)
    self.Params.s_sym.value = name
    self.Params.h_sym.value = h_sym



I think the problem lies with the create symbol node. See screenshots below. Seem like i just need a create symbol node with more properties, or just a 2d symbol node.


1. Design layer space




3d view space



Link to comment
  • 2 months later...

Hi Samuel,


Did you ever find an answer to this?  I'm up against the same problem and I cannot for the life of me figure out how to force something into the 2D component of a symbol.  I've tried playing with the code in Dom C's custom node but I'm not fluent enough in Python to get it working correctly.


I did find this:




I'm not sure if it's a legacy function or will work with new VW2022 workflows, but either way I haven't been able to successfully incorporate it into the script.  Any help you could provide would be much appreciated!  Thanks!

Link to comment

I think what you are looking for is AddObjectTo2DComp.


Prior to VW2019(??18??) symbols only had two parts 3D and 2D/Top Plan/Screen Plane. They now have 11.




Each of these 2D components is officially a Group inside the symbol. You can add any object you want to a 2D Component Group using AddObjectTo2DComp.


Set2DComponentGroup will take a handle to an existing group and set that group to be the selected component.

Get2DComponentGroup will return a handle to the group that is the existing component.


If you only want a standard symbol with a different 2D view then make a group that looks like you want the Top/Plan view to be and pass that to Set2DCompGroup


Bool1 := Set2DComponentGroup(HandleToSymbol, HandleToGroup, 10);


Where the Handles are whatever way you want to get the handle to the symbol and group.


Sorry for the Vectorscript instead of Python.



  • Like 1
Link to comment

Hi Pat,


Thanks so much for your reply.  I really need to learn Python as there are so many gaps in basic functionality (still!) with Marionette.  I actually had a question out to Dom C about this too, and he replied with a similar answer:


Creating Hybrid Symbols with Marionette in VW2022


I think I'll try my hand at creating a custom node that I can pass 2D components through, but I may need a little help!  I've invited you to that thread in case you're interested in progress or have any suggestions.  Thanks again!



Link to comment
  • 2 weeks later...

Chris solved his situation with putting the top/plan component on screen-plane and use set parent to move it into the symbol.
In the meantime I made an node for SetPlanar Ref. The includes Command (vs.Set2DComponentGroup) needs a group of screen-plane objects to work. So use the Set Planar Boolean and the group node for your geometry. For a hybrid symbol with 3D and top/plan the SetComponentGroup is not necessary. SetComponentGroup would need to set front, left, section views etc.


Script Set2DComponentGroup.vwx

  • Like 4
Link to comment
  • 1 year later...

I managed to write a python script in script palette for this function (converting multiple user selected objects to one 2D symbol) . I have two questions:

1. the newly created symbol is not placed in the center of the new object !!!

2. how do I export and share the script .py file with other users so that they import it from server and use it? 

Thank you



# written by NNT 27.9.2023

import vs;

objs = []

def GetBBoxCenter (h):        
        box = vs.GetBBox(h)
        topL2D = box[0]
        botR2D = box[1]
        center = [None, None]
        BB_width  = botR2D[0] - topL2D[0]
        BB_height = topL2D[1] - botR2D[1]
        center[0] = topL2D[0] + BB_width / 2
        center[1] = topL2D[1] - BB_height / 2
        center = tuple (center)
        return (center, BB_width)
def collect(handle):

# collect visible selected objects
vs.ForEachObject(collect, '((VSEL=TRUE))')
vs.AlrtDialog('Anzahl der ausgewählten Objekte: {}'.format(len(objs)))

# create new Symbol in Document
newSymNameDefault = 'YourNewSymbol'
newSymName = vs.StrDialog("Neues Symbol Name",newSymNameDefault)
h = vs.LNewObj()

h_sym = vs.GetObject(newSymName)

# add/set first obj to symbol
objSym = objs[0]
vs.SetPlanarRef(objSym, 0) # 0 is ref ID for Screen plane
vs.SetParent(objSym, h_sym)
vs.Set2DComponentGroup(h_sym, objSym, 10) # this command works for screen plane objects only

# replace all selected objs with new symbol
# get original symbol obj center and width for rotation angle comparison
objSymCenter, objSymWidth = GetBBoxCenter(objSym)
for i,obj in enumerate(objs):
		objCenter, objWidth = GetBBoxCenter(obj)
		rotAngle = 0
		if objWidth != objSymWidth:
			rotAngle = 90
		newSym = vs.Symbol(newSymName, objCenter, rotAngle)

vs.AlrtDialog('Symbol "{}" ist in Zubehör Manager'.format(newSymName))


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