Samuel Derenboim Posted December 29, 2021 Share Posted December 29, 2021 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 3d view space Quote Link to comment
Chris Busch Posted March 15, 2022 Share Posted March 15, 2022 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! Quote Link to comment
Pat Stanford Posted March 16, 2022 Share Posted March 16, 2022 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. HTH. 1 Quote Link to comment
Chris Busch Posted March 16, 2022 Share Posted March 16, 2022 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 Quote Link to comment
Anders Blomberg Posted March 25, 2022 Share Posted March 25, 2022 @Chris Busch how are you getting along with this? Do I understand this correctly that I can't create hybrid symbols if I don't know Python or Vectorscript? I enjoy fiddling around in Marionette and I'd love to learn how to create hybrids. Quote Link to comment
Pat Stanford Posted March 28, 2022 Share Posted March 28, 2022 @Anders BlombergSomeone needs to write the node to allow you to set the 2D portions of the symbol. After that is written you only have to use it as part of your Marionette network. I think @Chris Busch and @DomC have a node working that will let you set the Top/Plan view. I think something that works on any of the 2D Component Groups is still to be implemented. 1 Quote Link to comment
DomC Posted March 30, 2022 Share Posted March 30, 2022 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. Script Set2DComponentGroup.vwx 4 Quote Link to comment
Anders Blomberg Posted March 30, 2022 Share Posted March 30, 2022 @DomC Wonderful! I'll give this a try when I have the time! Quote Link to comment
NTT Posted September 27, 2023 Share Posted September 27, 2023 Hallo 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): objs.append(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) vs.SetOriginAbsolute(0,0,0) vs.BeginSym(newSymName) vs.Locus(0,0,0) h = vs.LNewObj() vs.EndSym() 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.ResetObject(objSym) vs.ResetObject(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.ResetObject(obj) vs.ResetObject(newSym) vs.DelObject(obj) vs.AlrtDialog('Symbol "{}" ist in Zubehör Manager'.format(newSymName)) Quote Link to comment
Recommended Posts
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.