SELECT THE EDGE OF ANY CYLINDER AND GET THE RADIUS AND DIRECTION IT IS GOING

SELECT THE EDGE OF ANY CYLINDER AND GET THE RADIUS AND DIRECTION IT IS GOING

cadking2k5
Advocate Advocate
1,118 Views
5 Replies
Message 1 of 6

SELECT THE EDGE OF ANY CYLINDER AND GET THE RADIUS AND DIRECTION IT IS GOING

cadking2k5
Advocate
Advocate

I want to be able to select Edge 1 and 2 like you do in the copy edge command and be able to get the cylinders radius and direction it is going. Any cylinder a new drawn one on edit on or 
CYL EDGE.JPG

0 Likes
1,119 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

Just some starting thoughts....

 

Applying (osnap) to the selection point with NEArest and CENter modes will give you two points, the distance between which will give you the radius.

 

If you don't select the edge at  a quadrant point [your pointer to Edge 2 looks at least very close to one], then applying (osnap) with QUAdrant mode would give you a third point, which along with the NEA/CEN points would define a plane, and the direction the cylinder is headed will be a normal from that plane.

 

The part I can't picture how to do is to determine in which of the two possible directions  the Solid extends from that defined plane.

Kent Cooper, AIA
0 Likes
Message 3 of 6

cadking2k5
Advocate
Advocate

Sorry I didn't make it clear but this is in customiztion autolisp

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

@cadking2k5 wrote:

Sorry I didn't make it clear but this is in customiztion autolisp


 

Certainly.  It can do all that I described [that's why I wrote "Applying (osnap)" with the parentheses -- (osnap) is an AutoLisp function]:

 

(setq
  pick (cadr (entsel "\nPick cylinder edge: "))
  nea (osnap pick "_nea")
  ctr (osnap pick "_cen")
  qua (osnap pick "_qua")
  rad (distance nea ctr)
)

 

The 'rad' variable is the radius you're after.  The 'nea' and 'ctr' and 'qua' variables define the plane of the cylinder end face, provided the 'nea' and 'qua' are not at the same location.  Those can be converted into an axis direction, but a big challenge is whether it can be determined in which of the two directions along that axis the cylinder is "aimed."  Another question:  in what format would you want the "direction" expressed -- as a unit vector, similar to the extrusion direction [210-code] in entity data?

Kent Cooper, AIA
0 Likes
Message 5 of 6

_gile
Consultant
Consultant

You can try something like this:

 

(if (setq cyl (car (entsel "\nSelect cylinder: ")))
  (if (= (cdr (assoc 0 (entget cyl))) "3DSOLID")
    (if (= (getpropertyvalue cyl "SolidType") "Cylinder")
      (alert (strcat "Height: "
                     (rtos (getpropertyvalue cyl "Height"))
                     "\nRadius: "
                     (rtos (getpropertyvalue cyl "Radius"))
             )
      )
      (alert "Selected solid is not a cylinder")
    )
    (alert "Selected object is not a 3D solid")
  )
  (alert "Nothing selected")
)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@_gile wrote:

You can try something like this:

 

....
(if (= (getpropertyvalue cyl "SolidType") "Cylinder") ....

 

Message 1 on this thread doesn't say one way or another, but from >this on another thread< I assume that it's showing compound [UNION'ed] 3D Solids, not primitives that could be detected in that way.

 

[This is a good reason for not posting essentially the same question in more than one place....]

Kent Cooper, AIA
0 Likes