Jump to content

make a selection set with all lwpolyline and circle


Recommended Posts

Posted

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 !

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • ectech

    11

  • wizman

    8

  • Lee Mac

    6

  • MSasu

    3

Top Posters In This Topic

Posted

This logical filter will create the requested selection set:

 

(setq set (ssget "_X" '((-4 . "<OR")
               (0 . "LWPOLYLINE")
               (0 . "CIRCLE")
              (-4 . "OR>"))))

 

Regards,

Posted

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")))))

Posted

@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!

Posted

thank you very much ! for your help !

Posted
@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

Posted

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 !

Posted

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

Posted
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

Posted

How about adding this in your loop:

 

(cond ((= (vlax-get-property item 'ObjectName) "AcDbCircle").........)
          
          
     ((= (vlax-get-property item 'ObjectName) "AcDbPolyline")..........))

Posted

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))

       

       
     

Posted
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.

Posted
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 !

Posted
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......

Posted

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..

Posted
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 :)

Posted

Thanks Lee, I know you forgot it because i learned it from you.:)

Posted
Thanks Lee, I know you forgot it because i learned it from you.:)

 

Thanks Wiz... I assume you are referring to this :D

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...