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.

Perpendicular circle. Finished. With a little help from my friends...

Started by Bob P, May 29, 2012, 11:43:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bob P

Here's what I have so far, but I can't seem to erase the first square.  See my failed attempts at the end of the macro.
Eventually I'll ask whether the person wants an arc, vector arc or a plane, but I want to get this squared away first.  I would rather use the first method, since a vector arc might accidentally be selected.
'pc.d3m
"This creates a perpendicular circle to a line

include "dcadalias.d3i"

setpoint "Set a point on the line and a point for the circle's center" 2
pointval x1 y1 z1 1
pointval x2 y2 z2 2
sys(1)=0

INPUT "What circle radius? ",r
rfix=r*sqrt(2)

>PerpendicularPlane
{
<width [rfix]
<pointxyz [x1, y1, z1]
<pointxyz [x2, y2, z2]

}

ENTNUM=SYS(9)
ENTITY(ENTNUM)
query ent_point,1 x1,y1,z1
query ent_point,2,x2,y2,z2
query ent_point,3,x3,y3,z3
sys(1)=0

>circle3
{
<pointxyz [x1, y1, z1]
<pointxyz [x2, y2, z2]
<pointxyz [x3, y3, z3]
}

'NOTE:  I'm trying to delete the first (square) plane here.
'How do I select it?  The following 2 lines don't work

'entnum2=sys(9)-1  'Hopefully gets the entnum of the square
'entity(entnum2)

'And this doesn't work either...
'>erase
'{
'<pointxyz [x3, y3, z3]
'}
END

prl

#1
BobP, yes very close. Try this.

Blue - syntax correction
Bold Black - added code


'pc.d3m

'This creates a perpendicular circle to a line

include "dcadalias.d3i"  'not used

setpoint "Set a point on the line and a point for the circle's center" 2
pointval x1 y1 z1 1
pointval x2 y2 z2 2
sys(1)=0

INPUT "What circle radius? ",r
rfix=r*sqrt(2)

>PerpendicularPlane
{
<width [rfix]
<pointxyz [x1, y1, z1]
<pointxyz [x2, y2, z2]

}

ENTNUM=SYS(9)
ENTITY(ENTNUM)
pointval x1,y1,z1, 1
pointval x2,y2,z2, 2
pointval x3,y3,z3, 3

sys(1)=0

>EraseLast 'remove the perpendicular plane
{
}


>circle3
{
<type 0
<pointxyz [x1, y1, z1]
<pointxyz [x2, y2, z2]
<pointxyz [x3, y3, z3]
}

END

Bob P

PRL,

Thanks for that better approach! 

As a point of inquiry, how do I select an entity by its entity number?

prl

Quote from: Bob P on May 29, 2012, 12:50:45 PM
As a point of inquiry, how do I select an entity by its entity number?

I read the above to mean you know the entity number and you want to highlight (select) the entity.  So if the entity number is in variable   entnum, here is the code:

Method 1:
.
.
.
Getattr entnum, type, select, laynum, group, red, green, blue
Putattr entnum, type, 1, laynum, group, red, green, blue
.
.
.

Method 2: (using newer query/change, aka dcadalias.d3i )
.
.
.
  entity entnum
  query Ent_Selected, eselected
  change Ent_Selected, 1
.
.
.

Bob P

Slaps head in embarrassment...

I've used the first method several times before.  I had to find the Query documentation in a later help file than I usually use.

Thanks!

Bob P

Here's my final macro.  it prompts for an arc, vector arc or plane.

'pc.d3m

'This creates a perpendicular circle to a line

setpoint "Set a point on the line and a point for the circle's center" 2
pointval x1 y1 z1 1
pointval x2 y2 z2 2
sys(1)=0

INPUT "What circle radius? ",r
method=0
INPUT "Arc, Vector arc, or Plane (A,V,P) (Enter for arc)", method$
if method$="A" then method=0
if method$="a" then method=0
if method$="V" then method=1
if method$="v" then method=1
if method$="P" then method=2
if method$="p" then method=2

rfix=r*sqrt(2)

>PerpendicularPlane
{
<width [rfix]
<pointxyz [x1, y1, z1]
<pointxyz [x2, y2, z2]

}

ENTNUM=SYS(9)
ENTITY(ENTNUM)
pointval x1,y1,z1, 1
pointval x2,y2,z2, 2
pointval x3,y3,z3, 3
sys(1)=0

>EraseLast 'remove the perpendicular plane
{
}

>circle3
{
<type [method]
<pointxyz [x1, y1, z1]
<pointxyz [x2, y2, z2]
<pointxyz [x3, y3, z3]
}

END