TurboCAD Forums
Turbo Talk => General Discussion => Topic started by: necronian on July 10, 2017, 06:19:19 AM

I'm trying to add linebores for shelving to my parametric parts. What I want to do is draw a series of circles 5mm in diameter 32mm apart, the number and location of circle is determined by the inside height of my cabinet. So if I have a cabinet 66" high I can fit 52 holes in my linebore. Then to find the starting center location of my first hole would be the difference between the height and 52*32mm divided by 2. (66(52*32mm))/2. I place my first hole at 0.2440944882" then draw 51 more holes 32mm apart.
However I can't figure out how to find the starting location for my first hole, the PPM doesn't seem to have a Floor or Int function. I saw that there was a Mod function which I could have used but it only supports integers. Is there a way to achieve what I am looking for?

If you round UP, maybe attached can be a workaround.
Torfinn

I am surprised that there isn't a floor function. There is one in the calculator palette.
I use floor with the other method of creating parametric symbols.

I am not sure what you guys meen with Floor, but guess it is to the top of Bottomplate in the cabinet, in ppm we write that ourself, it is the last Parameter in the PPM i showed.
Torfinn

I CAN'T SOLVE THE CAPTCHA! I'm as dumb as a robot.
nikkipollard: I know it's crazy, but Floor() doesn't work and I tried floor() but that consistently crashes Turbocad. The only usable documentation I found is at http://www3.turbocadcommunity.com/tikiindex.php?page=Parametric+Part+Manager and there isn't much to it.
Thanks Torfinn, but the issue I have is that I don't know the size ahead of time. The idea is for this to be a part of a much larger assembly, I'm getting the size by passing in another part and grabbing the Extents. We use tongue and groove construction, for example here is the working groove macro I wrote:
Input(part,groove_offset,thickness,part_offset,side);
x1=ExtentsX1(part);
x2=ExtentsX2(part);
y1=ExtentsY1(part);
y2=ExtentsY2(part);
LeftGroove = SetProperties(
Polyline(
Point(x1+part_offset+thickness,y2groove_offset),
Point(x1+part_offset+thickness,y1+groove_offset)
),
"Layer"="GROOVE");
RightGroove = SetProperties(
Polyline(
Point(x2part_offsetthickness,y1+groove_offset),
Point(x2part_offsetthickness,y2groove_offset)
),
"Layer"="GROOVE");
TopGroove = SetProperties(
Polyline(
Point(x2groove_offset,y2part_offsetthickness),
Point(x1+groove_offset,y2part_offsetthickness)
),
"Layer"="GROOVE");
BottomGroove = SetProperties(
Polyline(
Point(x1+groove_offset,y1+part_offset+thickness),
Point(x2groove_offset,y1+part_offset+thickness)
),
"Layer"="GROOVE");
NOGROOVE=Group();
Output(
IF(side==1,LeftGroove,
IF(side==3,RightGroove,
IF(side==2,TopGroove,
IF(side==4,BottomGroove,
NOGROOVE)))));

Thanks, then i understand, but i still dont know what you meen with Floor in a ppm :)
And Floor is not a command, by the list of legal commands.
Torfinn
Edit;
Now i know ;)

Floor and Ceil are math functions in most spreadsheets, programming languages, etc. Floor finds the largest integer less than or equal to the input so floor(5), floor(5.4) and floor(5.9999) all will return 5. Ceil is essentially the opposite operation.
I was complaining to a friend and he said that if turbocad is using IEEE double I can try to take advantage of that to round to the nearest integer. I tried it and it seems to work, although I'm not super happy with the solution because it's a hack.
Try,
c = 4503599627370496; //MAGIC NUMBER!
intermediate = 2.4 + c;
rounded = intermediate  c;
Fnt = TextFont(0,300,0,"Arial");
Fsty = TextStyle(MIDDLE, TOP, ITALIC, BOLD);
Output(Text(""+rounded+"", Fnt, Fsty));
The number 4503599627370496 is 2^52, which is the size of the mantissa of a double. I think. To be honest my grasp of floating point numbers isn't great and mostly half remembered from my long ago computer architecture courses in college.

necronian, THANK YOU !
That was truly a magic number :)
Then we can just make our own Floor and Ceiling ppm function, very nice.
Torfinn

I am sorry for revisiting an old thread.
This works for rounding off a number how do you use it for finding the floor or ceiling?

Hopefully I figured out another way,
Mod might work for me to work out the "ceiling" when dividing 2 numbers.
I am not a maths genius so I could be way off.
Use mod to find out the remainder
c=Mod(1000,170);
work out the difference between the "divisor" and the "remainder"
d=170c
add that to the "dividend"
e=1000+d
ceiling=e/170
It doesn't work if there isn't a remainder though. IF solves that.

A typo i guess, as Mod use , not /
c=Mod(1000,170); will work
Torfinn

Yes thanks