Grasshopper

algorithmic modeling for Rhino

I'm not entirely sure how to best summarize, as I'm unsure of the efficiency of my approach so far, but ultimately I'm trying to take a numerical variable (from the number slider preferably) and add leading zeros to it, outputting a final form such as 001, 002, 003, etc. 

I've run into the issue of my output, when using a number slider, returning values such as 001.0, 002.0, 003.0, etc due to the output of the number slider being in the decimal form x.0.

As I'm typing this, I realize I am going to have to refine my approach because a value of 010 would break the functionality of my current thinking, but the issue of removing the decimal and zero would remain.

My goal is to have the panel which reads 002.0 read 002

Any help would be appreciated. 

Views: 6902

Replies to This Discussion

Solved, but not necessarily in the ideal form. By adding an integer Primitive>Integer Component as a filter it removed the decimal and zero.

Hi Zack, what would be the wanted output if your input is 10 or more? Should that result in 010 or 0010? Or are your input values allway smaller than 10?

It would need to be 010. As 100 would need to be 100, not 00100.

I realized as I was posting this that even solving the integer problem wound't bring me to the final solution for my definition.

My list of potential input values will most certainly exceed 10.

Okay, understood, here is a simple VB scriptable component to achieve that: Edit: hmm, for your case I could have just said: use Format("{0:000}",x) in Evaluate or Expression component:

Attachments:

Awesome! Thanks man that will really help out.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service