cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

itos headache....

Patriot_1776
22-Sapphire II

itos headache....

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
BenLoosli
23-Emerald II
(To:KenFarley)

A little shorter version:

 

if a1_spring_od - floor(a1_spring_od) == 0
   title_1_len = '000'
else
   title_1_len = extract(itos((a1_spring_od-floor(a1_spring_od)+1)*1000),2,3)
endif
title_1_1 = itos(floor(a1_spring_od))+'.'+title_1_len
 
if a1_free_length - floor(a1_free_length) == 0
   title_2_len = '000'
else
   title_2_len = extract(itos((a1_free_length-floor(a1_free_length)+1)*1000),2,3)
endif
title_1_2 = itos(floor(a1_free_length))+'.'+title_2_len
 
if a1_wire_diameter - floor(a1_wire_diameter) == 0
   title_3_len = '000'
else
   title_3_len = extract(itos((a1_wire_diameter-floor(a1_wire_diameter)+1)*1000),2,3)
endif
title_1_3 = itos(floor(a1_wire_diameter))+'.'+title_3_len
 
dwg_title2 = title_1_1+' OD, '+title_1_2+' LONG, '+title_1_3+' WIRE DIAMETER,'

View solution in original post

7 REPLIES 7

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?

BenLoosli
23-Emerald II
(To:KenFarley)

A little shorter version:

 

if a1_spring_od - floor(a1_spring_od) == 0
   title_1_len = '000'
else
   title_1_len = extract(itos((a1_spring_od-floor(a1_spring_od)+1)*1000),2,3)
endif
title_1_1 = itos(floor(a1_spring_od))+'.'+title_1_len
 
if a1_free_length - floor(a1_free_length) == 0
   title_2_len = '000'
else
   title_2_len = extract(itos((a1_free_length-floor(a1_free_length)+1)*1000),2,3)
endif
title_1_2 = itos(floor(a1_free_length))+'.'+title_2_len
 
if a1_wire_diameter - floor(a1_wire_diameter) == 0
   title_3_len = '000'
else
   title_3_len = extract(itos((a1_wire_diameter-floor(a1_wire_diameter)+1)*1000),2,3)
endif
title_1_3 = itos(floor(a1_wire_diameter))+'.'+title_3_len
 
dwg_title2 = title_1_1+' OD, '+title_1_2+' LONG, '+title_1_3+' WIRE DIAMETER,'
Patriot_1776
22-Sapphire II
(To:BenLoosli)

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.

 

Patriot_1776
22-Sapphire II
(To:BenLoosli)

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.

Patriot_1776
22-Sapphire II
(To:KenFarley)

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.

Top Tags