Ok, this "itos" stuff is giving me a real headache. I see a bunch of solutions, but I'm not understanding how to implement them, so I'll be specific. I want to make the line below work and give me 3 decimal places fro all the parameters. It's completely retarded that you can't simply use the "[.3]" that you can in dwgs.
Anyways, here's what I'm trying to do to get the relation to work to make the parameter "DWG_TITLE2" work to fill out the BOM correctly. I've made it a flexible part, so it'd be nice to have it work parametrically to fill out the BOM.
DWG_TITLE2 = itos(A1_SPRING_OD) + " OD" + "," + " " + itos(A1_FREE_LENGTH) + " LONG," + itos(A1_WIRE_DIAMETER) + " WIRE DIAMETER,"
Thanks in advance!
Solved! Go to Solution.
A little shorter version:
Okay, here's the lengthy solution:
/* /* Build "DWG_TITLE2" from the pertinent parameters, each with three decimal /* places of precision. /* /* First, the Spring OD DWG_TITLE2 = ITOS ( floor ( A1_SPRING_OD ) ) + "." IF A1_SPRING_OD < 1.0 DWG_TITLE2 = "0." ENDIF DWG_TITLE2 = DWG_TITLE2 + EXTRACT ( ITOS ( floor ( 10^3 * ( 1 + A1_SPRING_OD - floor ( A1_SPRING_OD)))),2,3 ) DWG_TITLE2 = DWG_TITLE2 + " OD, " /* Second, the Free Length IF A1_FREE_LENGTH < 1.0 DWG_TITLE2 = DWG_TITLE2 + "0." ELSE DWG_TITLE2 = DWG_TITLE2 + ITOS ( floor ( A1_FREE_LENGTH ) ) + "." ENDIF DWG_TITLE2 = DWG_TITLE2 + EXTRACT ( ITOS ( floor ( 10^3 * ( 1 + A1_FREE_LENGTH - floor ( A1_FREE_LENGTH )))),2,3 ) DWG_TITLE2 = DWG_TITLE2 + " LONG, " /* Third, the Wire Diameter IF A1_WIRE_DIAMETER < 1.0 DWG_TITLE2 = DWG_TITLE2 + "0." ELSE DWG_TITLE2 = DWG_TITLE2 + ITOS ( floor ( A1_WIRE_DIAMETER ) ) + "." ENDIF DWG_TITLE2 = DWG_TITLE2 + EXTRACT ( ITOS ( floor ( 10^3 * ( 1 + A1_WIRE_DIAMETER - floor ( A1_WIRE_DIAMETER )))),2,3 ) DWG_TITLE2 = DWG_TITLE2 + " WIRE DIAMETER, "
Hope I didn't miss any parentheses there, but that's how I do these horrible things. Quite a lot of stuff for a simple thing, isn't it?
A little shorter version:
Thanks Ben! TOTALLY solved it. Dunno what kind of magic is behind that, but it flat works. Thanks bro!
Me, I can program only simple stuff, that's beyond my comprehension....
It is old code that I use for family tables to extract length, diameter or other variables needed for the part description of hardware items.
Good piece of code to stick in a reference note for future use.
I will certainly keep that little bit of magic around, thanks again! I have a compression spring that I made be able to fit almost any need as the driving parameters are all flexible. So, instead of having a huge family table (numbering in the thousands), this one spring pretty much does it all, and this bit of magic finishes making the BOM work.
If you like, PM me and I'll send you a copy. Not 100% perfect yet, I've got a minor tweak or 2 before I call it perfect, but if you want I'll send it to ya.
I saw a discussion of this in the past and was making some assemblies with springs. You can download spring models from McMaster Carr and they look cool, but they are typical dumb models. If you want the thing to be in your assembly it can be put in with some addition of features like planes for placement, but it's only in there at its free length, thus sticks through my beautiful assembly like a shipworm. So I, too, built a variable driven spring with the nice start and end coils, ground ends, etc. I think you might have been involved in the forum discussion at the time. It makes your assemblies look very nicely professional. I even did one for die springs (with the cool rectangular cross section) for those times when I need really strong springs. I family tabled the parts and can add new entries easily. I even added parameters to store the data from McMaster about spring constant, max load, etc.
I learned a lot about helical sweeps from that exercise. Too bad it was not applicable when I was trying to model a quarter turn fastener. That monster could only be slain with a set of equation driven curves and surfaces built with them.
Yeah, I probably was involved with that discussion. The geometry issues are my fave topics, as you can probably tell. I ended up with a spring I was happy with, and thanks to Ben's code, now it works to automatically fill out the BOM. A few more tweaks and I'll call it done. I refuse to use McMaster anything, we have a zillion-6 parameters here and so nothing works if I don't start with our start part.
The spring I made is flexible in all aspects, and will regenerate down to some truly bizarre non-real world) combinations, so, I managed to avoid having to do a family table which could end up with thousands of parts, which was my goal.