Jump to content

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

@Marionette.NodeDefinition
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
    vs.BeginSym(name)
    vs.Locus3D(0,0,0)
    h = vs.LNewObj()
    vs.EndSym()
    
    vs.Marionette_DisposeObj(h)
    
    h_sym = vs.GetObject(name)
        
    vs.SetParent(obj, h_sym)
    vs.ResetObject(obj)
    vs.ResetObject(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

 

image.png.81231d045891ee61d106c597b8232204.png

 

3d view space

image.png.55b9937c5f1c7f3b0d2ce1242ea78be6.png

 

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:

 

VS:Set2DComponentGroup

 

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.

 

image.png.9155617e37fde1d261c2f6fcc7933f9f.png

 

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.

 

HTH.

  • 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!

 

-Chris

Link to comment
  • 2 weeks later...

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


image.png.9a3ddef3816bb1837cbbf9baf91a687b.png
 
image.thumb.png.9fdbb04316ae8292a4e6e2ec711228ce.png

Script Set2DComponentGroup.vwx

  • Like 3
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...