Jump to content
Sign in to follow this  
jc4d

Complex suffix

Recommended Posts

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.

13973158.t.jpg

Here is the file:

Share this post


Link to post

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

Share this post


Link to post

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 by DomC

Share this post


Link to post
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 :D.

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

Share this post


Link to post
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

Share this post


Link to post

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

ubbthreads.php?ubb=download&Number=12876&filename=Screen%20Shot%202015-09-20%20at%2011.48.47%20AM.png

Edited by Kevin McAllister

Share this post


Link to post

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 :D

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.

Share this post


Link to post

You should use vs.Num2Str() instead of Num2StrF()

dim1 = vs.Num2Str(0, self.Params.dim1.value)

dim2 = vs.Num2Str(0, self.Params.dim2.value)

Share this post


Link to post
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 by Kevin McAllister

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...