ectech Posted January 5, 2010 Posted January 5, 2010 Dear all, I'm the beginner of autolisp, I would like to make a selection set with all lwpolyline and circle but I didn't know how make it. (setq set (ssget "x" (list (cons 8 (vlax-get-property object 'Name)) '(0 . "lwpolyline")) Anyone can help me ? thanks ! Quote
MSasu Posted January 5, 2010 Posted January 5, 2010 This logical filter will create the requested selection set: (setq set (ssget "_X" '((-4 . "<OR") (0 . "LWPOLYLINE") (0 . "CIRCLE") (-4 . "OR>")))) Regards, Quote
wizman Posted January 5, 2010 Posted January 5, 2010 Msasu, set is a lisp function also and not to be used as a variable. also: (setq myset (ssget "_X" (LIST '(0 . "LWPOLYLINE,CIRCLE") (cons 410 (getvar "CTAB"))))) Quote
MSasu Posted January 5, 2010 Posted January 5, 2010 @wizman: You are right, my mistake – have preserved the original variable name without noticing that issue. That’s embarrassing! Also, your proposed filtering is new for me (comma delimited types) – have learned something this morning. Thanks! Quote
ectech Posted January 5, 2010 Author Posted January 5, 2010 thank you very much ! for your help ! Quote
Lee Mac Posted January 5, 2010 Posted January 5, 2010 @wizman: You are right, my mistake – have preserved the original variable name without noticing that issue. That’s embarrassing! Also, your proposed filtering is new for me (comma delimited types) – have learned something this morning. Thanks! msasu, FYI any wcmatch string may be used in an ssget filter, i.e. (setq myset (ssget "_X" '((0 . "~INSERT")))) Means All Objects except INSERT's. Or perhaps: (setq myset (ssget "_X" '((0 . "*TEXT,*LINE")))) Will retrieve MTEXT,RTEXT,and TEXT, as well as LWPOLYLINE, POLYLINE, SPLINE, XLINE and LINE. Lee Quote
ectech Posted January 6, 2010 Author Posted January 6, 2010 Thanks ! And after selected all lwpolyline and circle, I will to convert all selection set to vla-object. Then I need to check this selection set have closed item or radius item or not. Is it correct ? (or (= (vlax-get-property (vlax-ename->vla-object item) 'closed) :vlax-false) (= (vlax-get-property (vlax-ename->vla-object item) 'radius) :vlax-false) );or thanks ! Quote
ectech Posted January 6, 2010 Author Posted January 6, 2010 I'm try to write some code to check both lwpolyline and circle but it failed to check the circle and got the following error. May be when the lisp checking the vl-object without this item it then return error. Is it possible to write a lisp to convert all circle to lwpolyline ? ActiveX Server returned the error: unknown name: CLOSED Quote
Lee Mac Posted January 6, 2010 Posted January 6, 2010 I'm try to write some code to check both lwpolyline and circle but it failed to check the circle and got the following error. May be when the lisp checking the vl-object without this item it then return error. Is it possible to write a lisp to convert all circle to lwpolyline ? Your error occurs because the Circle does not have the closed property. If you are trying to convert all Circles to LWPolylines, why are you collecting LWPolylines in your selection set? Also, as the Circle is a separate drawing object entirely, you will need to define how many segments you want your polyline to have. Lee Quote
wizman Posted January 6, 2010 Posted January 6, 2010 How about adding this in your loop: (cond ((= (vlax-get-property item 'ObjectName) "AcDbCircle").........) ((= (vlax-get-property item 'ObjectName) "AcDbPolyline")..........)) Quote
Lee Mac Posted January 6, 2010 Posted January 6, 2010 Example: (defun c:C2P (/ segs i ss ent rad cen theta 2pi lst) ;; Lee Mac ~ 06.01.10 (vl-load-com) (setq segs 100) ;; Number of Segments in Polyline (if (setq i -1 ss (ssget "_:L" '((0 . "CIRCLE")))) (while (setq ent (ssname ss (setq i (1+ i)))) (setq rad (cdr (assoc 40 (entget ent))) theta 0. cen (cdr (assoc 10 (entget ent))) 2pi (* 2 pi)) (entmake (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 segs) (cons 70 1)) (while (<= (setq theta (+ theta (/ 2pi segs))) 2pi) (setq lst (cons (cons 10 (polar cen theta rad)) lst))))) (entdel ent) (setq lst nil))) (princ)) Quote
ectech Posted January 6, 2010 Author Posted January 6, 2010 Your error occurs because the Circle does not have the closed property. If you are trying to convert all Circles to LWPolylines, why are you collecting LWPolylines in your selection set? Also, as the Circle is a separate drawing object entirely, you will need to define how many segments you want your polyline to have. Lee Thanks ! Lee because I have already a function to check all lwpolyline area and make a mark on each lwpolyline but if it is a cirlce, it will failed to check it. So I have a idea, group all lwpolyline and circle to selection set and then the function can make a mark on each item. Quote
Lee Mac Posted January 6, 2010 Posted January 6, 2010 Ok, well I hope my code helps you get closer to your goal. Quote
ectech Posted January 7, 2010 Author Posted January 7, 2010 Ok, well I hope my code helps you get closer to your goal. Thanks you your code. But I found that some problem. when I use your lisp to convert the circle to lwpolyline, may be it use 100 segment to build up this circle. compare with this new object and the old circle, the total area is different. If I use the lisp to check all circle and get the center point, can I use the bpoly command to draw a new polyline on it ? Because I use the bpoly command draw the lwpolyline on top of the circle, the area the same as circle. Thanks ! Quote
ectech Posted January 7, 2010 Author Posted January 7, 2010 How about adding this in your loop: (cond ((= (vlax-get-property item 'ObjectName) "AcDbCircle").........) ((= (vlax-get-property item 'ObjectName) "AcDbPolyline")..........)) thanks ! this is my code, but after I running the program got the bad argument type: VLA-OBJECT error. anything wrong ? (setq myset (ssget "_X" (LIST '(0 . "LWPOLYLINE,CIRCLE") (cons 410 (getvar "CTAB"))))) (setq ctr 0) (repeat (sslength sset) (setq item (ssname sset ctr)) (setq item (vlax-ename->vla-object item)) (cond ((= (vlax-get-property item 'ObjectName) "AcDbCircle") (command "-color" red )) ((= (vlax-get-property item 'ObjectName) "AcDbPolyline") (if (= (vlax-property-available-p (vlax-ename->vla-object item) "Closed" T) T) (progn...... Quote
wizman Posted January 7, 2010 Posted January 7, 2010 bpoly way is possible, also, you can use this principle to convert circle to polyline: (setq rad (vla-get-radius (Setq ron (vlax-ename->vla-object(car(entsel)))))) (setq cen (vlax-get ron 'center)) (Setq pt1 (polar cen pi rad)) (setq pt2 (polar cen 0 rad)) (command "pline" pt1 pt2 "c" "") (vla-setbulge (vlax-ename->vla-object (entlast)) 0 1.) (vla-setbulge (vlax-ename->vla-object (entlast)) 1 1.) got to run for work first.. Quote
Lee Mac Posted January 7, 2010 Posted January 7, 2010 bpoly way is possible, also, you can use this principle to convert circle to polyline: (setq rad (vla-get-radius (Setq ron (vlax-ename->vla-object(car(entsel)))))) (setq cen (vlax-get ron 'center)) (Setq pt1 (polar cen pi rad)) (setq pt2 (polar cen 0 rad)) (command "pline" pt1 pt2 "c" "") (vla-setbulge (vlax-ename->vla-object (entlast)) 0 1.) (vla-setbulge (vlax-ename->vla-object (entlast)) 1 1.) got to run for work first.. Ahh forgot about Bulge factors! Nice one Wiz Quote
wizman Posted January 7, 2010 Posted January 7, 2010 Thanks Lee, I know you forgot it because i learned it from you. Quote
Lee Mac Posted January 7, 2010 Posted January 7, 2010 Thanks Lee, I know you forgot it because i learned it from you. Thanks Wiz... I assume you are referring to this Quote
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.