jc4d Posted September 20, 2015 Share Posted September 20, 2015 Hi all, I´m creating my own parametric object but I´m facing few dead ends (so far related with texts). There are two variables that has to be "fixed" one is a prefix and then a "mid suffix". Really hard to explain... My object has a W as prefix, after that it comes the width value which is taken from the rectangle real value, then (here is the problem) I need a suffix X (the letter which will not change at all) and after that another value with the height. Of course I can make the suffix as a string but I would need a real value for the future and not a string. In this example you can see the prefix set as W and then the width and height, but in between this 2 values I need to put the letter X. Here is the file: Quote Link to comment
Kevin McAllister Posted September 20, 2015 Share Posted September 20, 2015 So its basically a W prefix and two dimensions separated by an "X"? Do you need the prefix or "X" to appear anywhere other than in the resulting text object? I think it would be a pretty easy node to custom make. The simple version would have only two inputs (the two dimension values) and you would hard code the prefix and "X". I think the function to used to bring everything together and output a single string is Concat (http://developer.vectorworks.net/index.php/VS:Concat). I don't think there's an existing Concat node. The node would output a string that you would then use as input into the text node. You would always be able to access the dimension values upstream of the custom node. I've been cutting and pasting simple bits of code to customize nodes. I don't have any real coding experience. Kevin Quote Link to comment
DomC Posted September 20, 2015 Share Posted September 20, 2015 (edited) Hi jc I can't find your object in die Drawing? With python you could just add strings like (variable1 + ' string'+ ' '+variable2) In marionette you can use the Math Node "add" A string variable in python (and marionette) is just a list of variable. That means: variable='hello' # h,e,l,l,o # and so variable[3] has a value from 'l' In marionette, you could use the data flow nodes to change lists (your string), split them etc. Edited September 20, 2015 by DomC Quote Link to comment
jc4d Posted September 20, 2015 Author Share Posted September 20, 2015 So its basically a W prefix and two dimensions separated by an "X"? Yes, exactly. Do you need the prefix or "X" to appear anywhere other than in the resulting text object? Nope, only in the resulting text object is enough. I think it would be a pretty easy node to custom make. The simple version would have only two inputs (the two dimension values) and you would hard code the prefix and "X". I think the function to used to bring everything together and output a single string is Concat (http://developer.vectorworks.net/index.php/VS:Concat). I don't think there's an existing Concat node. The node would output a string that you would then use as input into the text node. You would always be able to access the dimension values upstream of the custom node. Now this went to a really dark side to me, my code experience is bellow zero . I have experience in building custom objects in C4D xpresso and that´s why I´m happy to have a "visual" way of coding in VW as well. Cheers, Juan Quote Link to comment
jc4d Posted September 20, 2015 Author Share Posted September 20, 2015 Hi jc I can't find your object in die Drawing? With python you could just add strings like (variable1 + ' string'+ ' '+variable2) In marionette you can use the Math Node "add" Nothing happens if you double click on the object? Cheers, Juan Quote Link to comment
Kevin McAllister Posted September 20, 2015 Share Posted September 20, 2015 (edited) Here. Try this. It has two examples. One that preserves units. One that does not. I've used XPresso some too. I don't think Marionette is quite there yet but I'm sure it will be in time. Double click on the nodes to see the code. Kevin Edited September 20, 2015 by Kevin McAllister Quote Link to comment
jc4d Posted September 20, 2015 Author Share Posted September 20, 2015 Wow, thank you so much Kevin for your time and patience, it is perfect. Yes, now Marionette is kind of like the xpresso´s little sister Of course the approach is somehow different but there are still some similarities between them. The idea of this object is that it is so specific the representation in the drawings that the standard objects can´t do it and Marionette will allow me to do it and boost my workflow hugely. Cheers, Juan PS. Is there a way to get rid of the zeros after the dot?, like in my screenshot it shows 6.00 and I would need only the 6. Quote Link to comment
DomC Posted September 20, 2015 Share Posted September 20, 2015 You should use vs.Num2Str() instead of Num2StrF() dim1 = vs.Num2Str(0, self.Params.dim1.value) dim2 = vs.Num2Str(0, self.Params.dim2.value) Quote Link to comment
Pat Stanford Posted September 20, 2015 Share Posted September 20, 2015 If you don't need the dimension marks, here is another way to do this in pure Marionette without requiring a custom node. Quote Link to comment
Kevin McAllister Posted September 20, 2015 Share Posted September 20, 2015 (edited) PS. Is there a way to get rid of the zeros after the dot?, like in my screenshot it shows 6.00 and I would need only the 6. In my Concat Decimal version change as DomC suggests You should use vs.Num2Str() instead of Num2StrF() dim1 = vs.Num2Str(0, self.Params.dim1.value) dim2 = vs.Num2Str(0, self.Params.dim2.value) The 0 in the expression denotes zero decimal places. You can set it to anything up to 9 I believe.... (My decimal version uses vs.Num2Str(), the one with units uses Num2StrF().) KM Edited September 20, 2015 by Kevin McAllister Quote Link to comment
Kevin McAllister Posted September 20, 2015 Share Posted September 20, 2015 If you don't need the dimension marks, here is another way to do this in pure Marionette without requiring a custom node. Very cool. Nice example Pat. KM Quote Link to comment
jc4d Posted September 21, 2015 Author Share Posted September 21, 2015 Awesome, thank you everybody so much for the help, very appreciated Cheers, Juan 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.