DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Create line down centre of rectangle

Started by aqua, November 15, 2007, 11:56:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aqua

Designcad 13.13


I have some basiccad code that adds a rectangle - I want to now add a line down the centre
The new line has to run parallel to the longest sides

Does anyone have the code for this:

Regards Frank

'FTM 16/11/2007
sys(41)=1
'Setpoint so as to display instructions
SetPoint "Set 2 points for the length and one point for the width of the rectangular area, press Esc to end: ", 2
If Sys(1) < 2 Then end

Pointval x1 y1 z1 1
Pointval x2 y2 z2 2

'select item when created
sys(242)=1

'Note - third point is created by user
>2DBox
{
  <PointXYZ [x1,y1,0]
  <PointXYZ [x2,y2,0]
  <Type 1
  <Orientation 1
  }
'Now need to identify the 4 points of the newly created rectangle - and draw a line down the centre


prl

#1
Frank, I added the blue code. 


'FTM 16/11/2007
sys(41)=1
'Setpoint so as to display instructions
SetPoint "Set 2 points for the length and one point for the width of the rectangular area, press Esc to end: ", 2
If Sys(1) < 2 Then end

Pointval x1 y1 z1 1
Pointval x2 y2 z2 2
sys(1) = 0
'select item when created
sys(242)=1

'Note - third point is created by user
>2DBox
{
  <PointXYZ [x1,y1,0]
  <PointXYZ [x2,y2,0]
  <Type 1
  <Orientation 1
  }

entity  sys(9)
Pointval x1 y1 z1 1
Pointval x2 y2 z2 2
Pointval x3 y3 z3 3
Pointval x4 y4 z4 4

 
if abs(x2-x1) >= abs(y4-y1) then
>line
{
<pointxyz [(x1+x4)/2,(y1+y4)/2,0]
<pointxyz [(x2+x3)/2,(y2+y3)/2,0]
}
else
>line
{
<pointxyz [(x1+x2)/2,(y1+y2)/2,0]
<pointxyz [(x3+x4)/2,(y3+y4)/2,0]
}

endif

sys(80)=0
sys(1)=0

end 

aqua

Cool.
Thanks.

Regards Frank

My father always said - "An ounce of brains is worth a ton of energy"

Lar

It's late (early in the morning) so I may be cross-eyed, but isn't aqua's Setpoint line asking for 3 points but only allowing 2?

Lar

Bob P

Yup.  It looks like his prompt should read "Set points at opposite diagonal corners of the box".

prl

#5
No, I think this is the way Frank intended it.  The first two points define the length and angle of the box, the third is set with the >2dbox command itself (giving you a ghost preview of the width).