4DCES Posted February 4, 2012 Share Posted February 4, 2012 Hi all I have found this code that was earlier posted on this forum, I was wondering if it would be possible to change it. I need to be able to place a point on certain Autocad entities. For example start and end point of lines. Every vertice of a polyline. Start middle and end of arcs. Centre of circle. And insertion point of blocks. I have managed to change the code so it works with lines circles and blocks But can not seem to change it for arcs. Can any one point me in the right direction. Thanks Thanks ; Draw POINTs at POLYLINE vertexes ; and at (M)TEXT insertion points ;;; mfuccaro@hotmail.com 09.06.2003 ; (defun c:pts( / ss i elist zero first) (setvar "CMDECHO" 0) (command "UNDO" "begin") (setq ss (ssget) i 0) (repeat (sslength ss) (setq elist (entget (ssname ss i)) zero (cdr (assoc 0 elist))) (if (OR (= zero "TEXT") (= zero "MTEXT") (= zero "LWPOLYLINE") (= zero "CIRCLE") (= zero "LINE")) (while elist (setq first (car elist) elist (cdr elist)) (if (= 10 (car first)) (command "POINT" (cdr first))) )) (setq i (1+ i)) ) (command "undo" "end") (setvar "CMDECHO" 1) (princ) ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted February 4, 2012 Share Posted February 4, 2012 Here, try this, but it is predicted for LWPOLYLINE without ARCs... ARCs as separate objects are programmed as you wanted with points at start, end and middle point, LINES are also reprogrammed to consider start and end points... ; Draw POINTs at POLYLINE vertexes ; and at (M)TEXT insertion points ;;; mfuccaro@hotmail.com 09.06.2003 ; (defun c:pts ( / ss i elist zero first second third fourth ) (setvar "CMDECHO" 0) (command "UNDO" "begin") (setq ss (ssget) i 0) (repeat (sslength ss) (setq elist (entget (ssname ss i)) zero (cdr (assoc 0 elist))) (cond ((OR (= zero "TEXT") (= zero "MTEXT") (= zero "CIRCLE")) (progn (setq first (assoc 10 elist)) (command "POINT" (cdr first)) )) ((= zero "LWPOLYLINE") (progn (while elist (setq first (car elist) elist (cdr elist)) (if (= (car first) 10) (command "POINT" (cdr first))) ) )) ((= zero "LINE") (progn (setq first (assoc 10 elist) second (assoc 11 elist)) (command "POINT" (cdr first)) (command "POINT" (cdr second)) )) ((= zero "ARC") (progn (setq first (assoc 10 elist) second (assoc 40 elist) third (assoc 50 elist) fourth (assoc 51 elist)) (command "POINT" (polar (cdr first) (cdr third) (cdr second))) (command "POINT" (polar (cdr first) (cdr fourth) (cdr second))) (command "POINT" (polar (cdr first) (/ (+ (cdr third) (cdr fourth)) 2.0) (cdr second))) )) ) (setq i (1+ i)) ) (command "undo" "end") (setvar "CMDECHO" 1) (princ) ) M.R. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 5, 2012 Share Posted February 5, 2012 (edited) or maybe something like this: [b][color=BLACK]([/color][/b]defun c:vpoints [b][color=FUCHSIA]([/color][/b]/ ss en ed et vl el pl ce ra sa ea ia i c[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"PDMODE"[/color] 3[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]defun massoc [b][color=NAVY]([/color][/b]key alist / x nlist[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]foreach x alist [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]eq key [b][color=BLUE]([/color][/b]car x[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq nlist [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]cdr x[b][color=RED])[/color][/b] nlist[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]reverse nlist[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"3DFACE,ARC,CIRCLE,INSERT,LINE,LWPOLYLINE,SOLID,TRACE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq en [b][color=MAROON]([/color][/b]ssname ss 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq ed [b][color=MAROON]([/color][/b]entget en[b][color=MAROON])[/color][/b] et [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 0 ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]cond [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]= et [color=#2f4f4f]"LWPOLYLINE"[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq vl [b][color=BLUE]([/color][/b]massoc 10 ed[b][color=BLUE])[/color][/b] el [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 38 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]foreach p vl [b][color=BLUE]([/color][/b]setq pl [b][color=RED]([/color][/b]cons [b][color=PURPLE]([/color][/b]trans [b][color=TEAL]([/color][/b]list [b][color=OLIVE]([/color][/b]car p[b][color=OLIVE])[/color][/b] [b][color=OLIVE]([/color][/b]cadr p[b][color=OLIVE])[/color][/b] el[b][color=TEAL])[/color][/b] en 0[b][color=PURPLE])[/color][/b] pl[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][b][color=GREEN]([/color][/b]= et [color=#2f4f4f]"ARC"[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq ce [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 10 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] ra [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 40 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] sa [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 50 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] ea [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 51 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] ia [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]> sa ea[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]+ [b][color=PURPLE]([/color][/b]- [b][color=TEAL]([/color][/b]* 2 pi[b][color=TEAL])[/color][/b] sa[b][color=PURPLE])[/color][/b] ea[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]- ea sa[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] pl [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]trans [b][color=PURPLE]([/color][/b]polar ce sa ra[b][color=PURPLE])[/color][/b] en 0[b][color=RED])[/color][/b] pl[b][color=BLUE])[/color][/b] pl [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]trans [b][color=PURPLE]([/color][/b]polar ce ea ra[b][color=PURPLE])[/color][/b] en 0[b][color=RED])[/color][/b] pl[b][color=BLUE])[/color][/b] pl [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]trans [b][color=PURPLE]([/color][/b]polar ce [b][color=TEAL]([/color][/b]+ sa [b][color=OLIVE]([/color][/b]* ia 0.5[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b] ra[b][color=PURPLE])[/color][/b] en 0[b][color=RED])[/color][/b] pl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]T [b][color=GREEN]([/color][/b]foreach g '[b][color=BLUE]([/color][/b]10 11 12 13[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]and [b][color=RED]([/color][/b]assoc g ed[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]setq pl [b][color=PURPLE]([/color][/b]cons [b][color=TEAL]([/color][/b]trans [b][color=OLIVE]([/color][/b]cdr [b][color=GRAY]([/color][/b]assoc g ed[b][color=GRAY])[/color][/b][b][color=OLIVE])[/color][/b] en 0[b][color=TEAL])[/color][/b] pl[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]ssdel en ss[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq i 0 c 0[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]foreach p pl [b][color=NAVY]([/color][/b]and [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]member p [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]member p pl[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq c [b][color=GREEN]([/color][/b]1+ c[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"POINT"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 10 p[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq i [b][color=MAROON]([/color][/b]1+ i[b][color=MAROON])[/color][/b] pl [b][color=MAROON]([/color][/b]cdr pl[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]princ [b][color=NAVY]([/color][/b]strcat [b][color=MAROON]([/color][/b]rtos i 2 0[b][color=MAROON])[/color][/b] [color=#2f4f4f]" Atom Point List vs "[/color] [b][color=MAROON]([/color][/b]rtos c 2 0[b][color=MAROON])[/color][/b] [color=#2f4f4f]" Unique POINTs"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] You can manipulate the filter list to remove the faces or solids etc. -David Edited February 5, 2012 by David Bethel add INSERTs & (trans LWPLines ) Quote Link to comment Share on other sites More sharing options...
elfert Posted February 5, 2012 Share Posted February 5, 2012 Nice! but what if i want a point in a insertion point of a Autocad mechanical 2011 content library item, is that possible? Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 5, 2012 Share Posted February 5, 2012 Nice! but what if i want a point in a insertion point of a Autocad mechanical 2011 content library item, is that possible? What exactly are they? -David Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 5, 2012 Share Posted February 5, 2012 Another, using curve functions: (defun c:points ( / e i j l s x ) (defun _point ( p ) (entmake (list '(0 . "POINT") (cons 10 p))) ) (if (setq s (ssget '((0 . "*POLYLINE,LINE,ARC,CIRCLE,INSERT")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (entget e) ) (cond ( (eq "LINE" (setq x (cdr (assoc 0 l)))) (_point (cdr (assoc 10 l))) (_point (cdr (assoc 11 l))) ) ( (wcmatch x "*POLYLINE") (repeat (setq j (1+ (fix (vlax-curve-getendparam e)))) (_point (vlax-curve-getpointatparam e (setq j (1- j)))) (if (not (equal '(0 0 0) (vlax-curve-getsecondderiv e j))) (_point (vlax-curve-getpointatparam e (+ j 0.5))) ) ) ) ( (eq "CIRCLE" x) (_point (trans (cdr (assoc 10 l)) e 0)) ) ( (eq "ARC" x) (_point (vlax-curve-getstartpoint e)) (_point (vlax-curve-getendpoint e)) (_point (vlax-curve-getpointatparam e (/ (+ (vlax-curve-getstartparam e) (vlax-curve-getendparam e)) 2.0) ) ) ) ( t (_point (trans (cdr (assoc 10 l)) e 0)) ) ) ) ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
elfert Posted February 5, 2012 Share Posted February 5, 2012 What exactly are they? -David They are like normal holes, through holes, thread holes and Auto cad mechanical can make in top view of this. An in the center of this holes i would like a point in a layer because the plasma cutter program can read this points that is why i am asking. elfert Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 5, 2012 Share Posted February 5, 2012 They are like normal holes, through holes, thread holes and Auto cad mechanical can make in top view of this. An in the center of this holes i would like a point in a layer because the plasma cutter program can read this points that is why i am asking. elfert The question would be what type of Autocad entities are they? INSERTs, Proxy_entities, 3DSOLIDS. The LIST command may enlighten us. -David Quote Link to comment Share on other sites More sharing options...
elfert Posted February 5, 2012 Share Posted February 5, 2012 The question would be what type of Autocad entities are they? INSERTs, Proxy_entities, 3DSOLIDS. The LIST command may enlighten us. -David I can only say that they are call STDPART2D in AutoCad mechanical. Like if you make a circle and list it its called circle. elfert Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 6, 2012 Share Posted February 6, 2012 4DCES, Please read the CODE POSTING GUIDELINES and edit your post. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 6, 2012 Share Posted February 6, 2012 I can only say that they are call STDPART2D in AutoCad mechanical. Like if you make a circle and list it its called circle. elfert My guess is that they are proxie_entities and therefore not much use in plain autoplisp. Sorry -David Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.