har Posted September 23, 2016 Share Posted September 23, 2016 Hi all, I've just noticed a problem with one of my Marionette Object Nodes. It instances a symbol from the ressource browser and draws some rectangles based on user defined parameters. I've saved it as a Smart Symbol to my ressources. When double clicking it in the ressource browser to insert it, the first one works okay. Every further instance I create however, will be only the default symbol instance, no further Marionette functionality. Drag and Drop from the ressource browser works fine. I hope this makes sense, please refer to the file attached. What is causing this behaviour? Is there any way for me to fix this? Thanks in advance for any assistance! 16-09-23_BlankPanelLibrary.vwx Quote Link to comment
AlanW Posted September 23, 2016 Share Posted September 23, 2016 (edited) Hi, am extremely new to Python, in your node is that a use of definitions and dictionaries? Its a lovely piece of work. Something to aspire to. Edited September 24, 2016 by Alan Woodwell Quote Link to comment
Marionette Maven Marissa Farrell Posted September 23, 2016 Marionette Maven Share Posted September 23, 2016 @har, I'll have to inquire about this. I'm seeing this both with the green symbol you've created as well as if I were to make a red symbol. I think it MAY have to do with a naming conflict somewhere. The best advice I can offer you for now would be to duplicate your Marionette Object on the drawing area rather than trying to always insert it from the RM, at least that could help to alleviate the extra clicks you're having to do with your current process... I'll report back if I learn anything! Quote Link to comment
har Posted September 26, 2016 Author Share Posted September 26, 2016 On 23.9.2016 at 1:49 PM, Alan Woodwell said: Hi, am extremely new to Python, in your node is that a use of definitions and dictionaries? Its a lovely piece of work. Something to aspire to. Stop it, I'm blushing I'm not using neither definitions nor dictionaries for this - way to high level. Python is actually a very easy-to-learn language - provided you understand some basic concepts of programming. It's probably a nice example to start from, so I've taken a few minutes to comment out my code - Something you should always do anyway! @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): this = Marionette.Node( 'Rack Panel Symbol' ) this.SetDescription( 'Creates a Rack Panel Symbol' ) #These create a Popup in the Node's OIP - Refer to: http://developer.vectorworks.net/index.php/Marionette_Implement_a_Node#Object_Info_Palette_-_Shape_Pane type = Marionette.OIPControl( 'Panel Type', Marionette.WidgetType.Popup, 0, ['Blank','Vented','Security','Clamp'] ) ru = Marionette.OIPControl( 'RU Height', Marionette.WidgetType.Popup, 0, ['1','2','3','4'] ) def RunNode(self): #All vs.XXX functions are "normal" Vectorscript functions. #Refer to: http://developer.vectorworks.net/index.php/VS:Function_Reference # #GLOBAL VARIABLES AND INPUTS # typelst = ['Blank','Vented','Security','Clamp'] #Copy list of Popup options 1 rulst = ['1','2','3','4'] #Copy list of Popup options 2 oneRU = 44.45 #global measurement for one "Rack Unit" height in millimeters rackwidth = 482.6 #global measurement for width of a 19" rack device in mm heightoffset = 4 #offset of drawn rectangles in Y widthoffset = 14 #offset of drawn rectangles in X type = self.Params.type.value #This only returns an Index value of the selected Popup Option ru = self.Params.ru.value #This only returns an Index value of the selected Popup Option name = 'Blank_'+rulst[ru] #Create string to find symbol # (rulst[ru] is the "selectionth" (ru) index of the selection copy (rulst) -> Therefor, the value selected # #CREATION OF SYMBOL 'Blank_#' # vs.Symbol(name,0,0,0) #symbol instance based on "name" above - Refer to: http://developer.vectorworks.net/index.php/VS:Symbol # #ATTACHING RECORD TO SYMBOL (to later find out how many of which type) # handle = vs.LNewObj() #handle to symbol for next step vs.SetRecord(handle, 'RackPanelRecord' ) #attach record to object vs.SetRField(handle, 'RackPanelRecord', 'RUheight', rulst[ru]) #write to record field vs.SetRField(handle, 'RackPanelRecord', 'Type', typelst[type]) #write to record field # #MAKING DIFFERENT "TYPES" # #if Popup Option "Type" is "Vented" if typelst[type] == 'Vented': vs.Rect(widthoffset,heightoffset, rackwidth-widthoffset,float(rulst[ru])*oneRU-heightoffset) #Make a rectangle handle = vs.LNewObj() #Handle to rectangle for next step vs.SetClass(handle,'KW_racklayout-Panel-Vent') #assign rectangle to class #if Popup Option "Type" is "Security" elif typelst[type] == 'Security': vs.Rect(widthoffset,heightoffset, rackwidth-widthoffset,float(rulst[ru])*oneRU-heightoffset) #Make a rectangle handle = vs.LNewObj() #Handle to rectangle for next step vs.SetClass(handle,'KW_racklayout-Panel-Secu') #assign rectangle to class #if Popup Option "Type" is "Clamp" elif typelst[type] == 'Clamp': vs.Symbol(('ClampPnl_'+rulst[ru]),0,0,0) #Make a ClampPnl symbol #There's only two version of Clamp Panels in the file (for 1 & 2 RU) as those are the only valid options. Error handling is ignored... vs.Group() #Group it all together #Not entirely neccessary (creates group in group) but I've made a habit of it as it makes some of my workflows easier. @MarissaF Thanks, please keep me updated. The proposed workflow is what I'm doing now. Problem is, I'm preparing this for all my colleagues and the poor bastards are just now switching to Vectorworks - They have enough other stuff to worry about Quote Link to comment
har Posted September 26, 2016 Author Share Posted September 26, 2016 And while I'm at it, someone could help me clean up my code: .... type = Marionette.OIPControl( 'Panel Type', Marionette.WidgetType.Popup, 0, ['Blank','Vented','Security','Clamp'] ) .... type = self.Params.type.value #This only returns an Index value of the selected Popup Option Is there any way to directly access the selected value, rather than only its index? For the nodes I'm doing, it doesn't make a huge difference. But it is kind of unnerving... Quote Link to comment
Marionette Maven Marissa Farrell Posted September 26, 2016 Marionette Maven Share Posted September 26, 2016 5 hours ago, har said: And while I'm at it, someone could help me clean up my code: .... type = Marionette.OIPControl( 'Panel Type', Marionette.WidgetType.Popup, 0, ['Blank','Vented','Security','Clamp'] ) .... type = self.Params.type.value #This only returns an Index value of the selected Popup Option Is there any way to directly access the selected value, rather than only its index? For the nodes I'm doing, it doesn't make a huge difference. But it is kind of unnerving... Here's an example - if you define the list outside of your OIP control in the Params class, you can extract the information from it in the RunNode definition later. Let me know if it's unclear, I can go into further detail if you'd like. @Marionette.NodeDefinition class Params(metaclass = Marionette.OrderedClass): this = Marionette.Node( "ReturnNameInsteadOfIndex" ) this.SetDescription('') list = ['Add', 'Subtract', 'Intersect'] op = Marionette.OIPControl( 'operation', Marionette.WidgetType.Popup, 0, list) op.SetDescription('') out = Marionette.PortOut() out.SetDescription('') def RunNode(self): self.Params.out.value = self.Params.list[self.Params.op.value] Quote Link to comment
har Posted September 27, 2016 Author Share Posted September 27, 2016 Hi Marissa, thanks, that does clean things up quite a bit. AND it reminds me of another topic I had actually already crossed off as impossible: Say I generate a list using the GetFilesInFolder function - to find all jpg image files in a specific directory - and then pass that on to a popup that should also work. Or wont it? I'm going to try anyway but sadly I'm busy with other work the next few days.... Quote Link to comment
Marionette Maven Marissa Farrell Posted September 27, 2016 Marionette Maven Share Posted September 27, 2016 1 hour ago, har said: Say I generate a list using the GetFilesInFolder function - to find all jpg image files in a specific directory - and then pass that on to a popup that should also work. Or wont it? In my experience, it could work, but likely not how you would want. Unfortunately at this moment, OIP controls don't have the capability to dynamically update, so your list may not always be up to date. I think, although I'm not sure if it works every time, that if you modify your node script in some way any time you add/delete jpgs from your referenced directory that it may update to reflect those changes, although it's not documented to absolutely work. I'd be happy to go over the limitations and why it cannot do this the way that we all would need it to, if you'd like, and if you do end up giving it a try, please report back on your attempts. It's useful to see how users are trying to use Marionette and where it is lacking. Definitely helps when I go back to report enhancement requests to the backend stuff where I don't get to play around much! 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.