Skip to main content
Patriot_1776
22-Sapphire II
December 3, 2018
Solved

itos headache....

  • December 3, 2018
  • 1 reply
  • 3752 views

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!

 

Best answer by BenLoosli

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,'

1 reply

21-Topaz II
December 3, 2018

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?

BenLoosli23-Emerald IIIAnswer
23-Emerald III
December 3, 2018

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,'
21-Topaz II
December 4, 2018

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.