Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Draw 3dpoly from a list

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
291 Views, 5 Replies

How to Draw 3dpoly from a list

Hi,

I want to convert a 3d circle to a 3dpolyline. but I don't exactly how to do it.

Steps:
Measure the circle into points: lenght of segment = 1
Make a selection set of the 3d-points: (setq ssp (ssget "x" '((0 . "point"))))
Add the 3d-points to a list: ???
Draw a closed 3dPoly with the points from the list: ???

Can anyone help me?
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Hi,

Not sure, but you can try this.

Function Test

When you pick a circle it converts it to a 3Dpoly.




(defun convCirc3dpoly (center rad segment / an ca ptlist model 3dpl)

(setq an (* 2.0 (sin (/ (* 0.5 segment) rad))) ca 0)

(while (< ca (* pi 2))

(setq ptlist (cons (polar center ca rad) ptlist) ca (+ ca an))

)

(setq model (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))

(setq 3dpl (vlax-invoke model 'Add3DPoly (apply 'append ptlist)))

(vla-put-closed 3dpl :vlax-true)

3dpl

)

(defun c:Test ()

(vl-load-com)

(if (and (setq ename (entsel) elist (entget (car ename)))(= (cdr (assoc 0 elist)) "CIRCLE"))

(if (convCirc3dpoly (cdr (assoc 10 elist))(cdr (assoc 40 elist)) 1.0)

(vla-delete (vlax-ename->vla-object (car ename)))

)

)

)


Hope that this is what you want.

Cheers

Harrie







Edited by: H.vanZeeland on Dec 23, 2008 1:46 PM



Edited by: H.vanZeeland on Dec 23, 2008 1:50 PM
Message 3 of 6
Anonymous
in reply to: Anonymous

Unless you have some reason to need to move parts of the resulting 3DPolyline from the plane of the
original Circle, you can make it a true Polyline circle, rather than an approximation with line
segments, if you use a 2D (lightweight) Polyline. If the original Circle is not in the XY plane of
the World Coordinate System, you'd need to set a UCS to match it first. Conveniently, using the
OBject option for a new UCS makes the Circle's center point 0,0,0. You can just make a Donut with
both inside and outside diameters equal to the diameter of the Circle.

{code}
(setq
cir (car (entsel "\nSelect Circle to convert to Polyline: "))
cirdia (* 2 (cdr (assoc 40 (entget cir))))
); end setq
(command
"_.ucs" "_new" "_object" cir
"_.donut" cirdia cirdia '(0 0 0) ""
"_.ucs" "_previous"
"_.erase" cir "" ; [omit if you want to keep the Circle]
); end command
{code}

--
Kent Cooper


ee_gdd wrote...
Hi, I want to convert a 3d circle to a 3dpolyline. but I don't exactly how to do it. Steps: Measure
the circle into points: lenght of segment = 1 Make a selection set of the 3d-points: (setq ssp
(ssget "x" '((0 . "point")))) Add the 3d-points to a list: ??? Draw a closed 3dPoly with the points
from the list: ??? Can anyone help me?
Message 4 of 6
Anonymous
in reply to: Anonymous

Or, if you do want a line-segmented Polyline, try the attached. Choose the EXisting option, pick a
Circle, give it a number of segments, and when it asks for Maximum Displacement, give it zero.

It asks for the number of segments, and divides the selected object's length equally. If you go for
a fixed segment length of 1, you'll almost always end up with a closing segment that's shorter than
the rest, which I wouldn't want, but that may suit your needs. The attached could easily be made to
ask for a maximum segment length and divide the Circle equally into segments of no more than that
length, or of approximately that length if being slightly longer would also be acceptable.

It will also make a lightweight Polyline [unless the selected object is a 3DPolyline], but could
easily be converted to make it a 3DPolyline instead, and/or to eliminate all the other options and
tailor it just to the convert-a-Circle-to-a-3DPolyline routine.

--
Kent Cooper


ee_gdd wrote...
Hi, I want to convert a 3d circle to a 3dpolyline. but I don't exactly how to do it. Steps: Measure
the circle into points: lenght of segment = 1 Make a selection set of the 3d-points: (setq ssp
(ssget "x" '((0 . "point")))) Add the 3d-points to a list: ??? Draw a closed 3dPoly with the points
from the list: ??? Can anyone help me?
Message 5 of 6
Anonymous
in reply to: Anonymous


try the POLYGON command with as many sides as you
need (example 200)


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,
I want to convert a 3d circle to a 3dpolyline. but I don't exactly how to do
it. Steps: Measure the circle into points: lenght of segment = 1 Make a
selection set of the 3d-points: (setq ssp (ssget "x" '((0 . "point")))) Add
the 3d-points to a list: ??? Draw a closed 3dPoly with the points from the
list: ??? Can anyone help me?
Message 6 of 6
Anonymous
in reply to: Anonymous

Like the attached, for instance....
--
Kent Cooper


"Kent Cooper" wrote...
....
It ... could easily be converted ... to eliminate all the other options and
tailor it just to the convert-a-Circle-to-a-3DPolyline routine.

--
Kent Cooper

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report