Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Does anyone know of a LISP routine which will draw lines from the center/insertion point of multiple objects to 0,0,0 ?
Solved! Go to Solution.
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
greenj1 wrote:Does anyone know of a LISP routine which will draw lines from the center/insertion point of multiple objects to 0,0,0 ?
May i ask as to whats the purpose of this exercise? just curious is all ![]()
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I have a number of objects surrounding a sphere (thousands) which I would like to create lines from to the center of the sphere (co-ords 0,0,0) and then sweep the lines to create cylinders which I will boolean from the sphere.
Hope that makes sense. Any suggestions ?
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
greenj1, wrote:
I have a number of objects surrounding a sphere (thousands) which I would like to create lines from to the center of the sphere
(co-ords 0,0,0) and then sweep the lines to create cylinders which I will boolean from the sphere.
...
Objects are circles?
Henrique
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Here is my quick and dirty version of it.
(defun c:test (/ esel cp)
(setq esel (entsel "\nSelect circle: ")
cp (cdr (assoc 10 (entget (car esel))))
)
(command "line" cp "0,0,0" "")
(princ)
)
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
greenj1 wrote:I have a number of objects surrounding a sphere (thousands) which I would like to create lines from to the center of the sphere (co-ords 0,0,0) and then sweep the lines to create cylinders which I will boolean from the sphere.
....
Based on these assumptions:
1. The objects could be of multiple types but all with insertion or insertion-like points [below assumes Circles, Points, and Blocks, but you could include Text/Mtext or some other things, and/or remove one or more types];
2. They might be in various orientations/coordinate systems [since they surround a sphere];
3. You can select them collectively somehow [via window(s) or something], and want to do that rather than pick one at a time;
4. You want the Lines on the current Layer;
then the following seems to do the Lines portion of what I think you're asking, in limited testing:
(setq ss (ssget '((0 . "CIRCLE,POINT,INSERT"))))
(repeat (sslength ss)
(setq ent (ssname ss 0))
(entmake
(list
'(0 . "LINE")
(cons 10 (trans (cdr (assoc 10 (entget ent))) ent 0))
;;; (trans) needed for Circles/Blocks when not in WCS
'(11 0.0 0.0 0.0)
); list
); entmake
(ssdel ent ss)
); repeat
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Kent you are the man ! Perfect.
One last question. Would it be possible for the lines to go to 0,0 but stay relative to their z co-ordinates ?
I may need to keep the booleans horizontal for a cleaner print (I am 3D printing this model) as the resolution in the Z is far higher than x,y.
Many thanks for your help ![]()
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
greenj1 wrote:.... Would it be possible for the lines to go to 0,0 but stay relative to their z co-ordinates ?
....
If I understand what you're asking correctly [run Lines from the object point to 0,0 in XY but with both Line ends at the Z coordinate of the object point, in the WCS], this does that:
(setq ss (ssget '((0 . "CIRCLE,POINT,INSERT"))))
(repeat (sslength ss)
(setq
ent (ssname ss 0)
dxf10 (cons 10 (trans (cdr (assoc 10 (entget ent))) ent 0)); object point, in WCS
;;; (trans) needed for Circles/Blocks when not in WCS
); setq
(entmake
(list
'(0 . "LINE")
dxf10
(list 11 0.0 0.0 (cadddr dxf10)); use Z coordinate of object point
); list
); entmake
(ssdel ent ss)
); repeat
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try a mod of Kent's, and, note that circles with a x,y of 0,0 make the '0 length' LINEs:
(defun KC_liner ( / ss rq p00 cp ncp )
(setq p00 '(11 0.0 0.0 0.0) rq 0
ss (ssget "x" '((0 . "CIRCLE,POINT,INSERT")))
' remove the "X" to manually select the circle entities
(repeat (sslength ss)
(setq ent (ssname ss 0) rq (1+ rq)
; (trans) needed for Circles/Blocks when not in WCS
cp (trans (cdr (assoc 10 (entget ent))) ent 0)
ncp (list (car cp) (cadr cp) 0.0) )
(entmake (list '(0 . "LINE") (cons 10 ncp) p00 ) ); entmake
(ssdel ent ss)
;;(p_"rq")(W_" 1")
); repeat
rq )
Re: Line from origin to object centers
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Kent once again thankyou, this works perfectly on the circles I have tested it on.
However my circles have to be converted into 3D polylines. The lisp does not seem to work on them !
I assumed they would have an inserition point or centre and it would work the same way.
Any suggestions ?


