Author Topic: Help : point to circle & circle to point lisp  (Read 3422 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
Help : point to circle & circle to point lisp
« on: April 05, 2017, 10:46:06 AM »
Hi i am using this code to convert points to circle and circlew to points
The problem is When i run this code change all the points of my drawing to circles or all my circles to points.

I want give me the option to select the circles or the points , and the change only the selected points or circles.

Can any on help.

Thanks

Code - Auto/Visual Lisp: [Select]
  1. (defun c:P2C ()
  2. (command "setvar" "clayer" "0")
  3. (COMMAND "_layer" "_m" "layer 1" "_c" "10" "" "")
  4. (setq sset (ssget "_X" '((0 . "POINT"))) i 0)
  5. (if sset
  6.   (repeat (sslength sset)    
  7.     (setq ent (ssname sset i))
  8.     (entmake
  9.       (list
  10.         (cons 0 "CIRCLE")
  11.         (cons 10 (cdr (assoc 10 (entget ent))))
  12.         (cons 40 0.2) ;circle size, change the 10.0 to whatever you want
  13.       )
  14.     )
  15.     (entdel ent)
  16.     (setq i (1+ i))
  17.   )
  18. )
  19.  (setvar 'pdmode 0)
  20.  
  21. )
  22.  
  23. (defun C:C2P (/ ss)
  24. (command "setvar" "clayer" "0")
  25. (COMMAND "_layer" "_m" "layer 1" "_c" "10" "" "")
  26. (defun MakePoint (dxfpt)
  27. (entmakex (list '(0 . "POINT")
  28. ;(cons 8 "0")   ; layer name here
  29. dxfpt ))
  30. )
  31. (setq ss (ssget "_X" '((0 . "CIRCLE"))))
  32. (function (lambda (x) (MakePoint (assoc 10 (entget x)))
  33. (vla-delete (vlax-ename->vla-object x))
  34. )
  35. )
  36. )
  37. )
  38.  

ChrisCarlson

  • Guest
Re: Help : point to circle & circle to point lisp
« Reply #1 on: April 05, 2017, 10:54:27 AM »
These are the two lines which you first need to change. My suggestion would be to incorporate LM:SelectIf (http://www.lee-mac.com/selectif.html)

Code - Auto/Visual Lisp: [Select]
  1. (setq sset (ssget "_X" '((0 . "POINT"))) i 0)

Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssget "_X" '((0 . "CIRCLE"))))

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Help : point to circle & circle to point lisp
« Reply #2 on: April 05, 2017, 12:59:59 PM »
Try the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:p2c ( / e i s )
  2.     (if (setq s (ssget "_:L" '((0 . "POINT"))))
  3.         (repeat (setq i (sslength s))
  4.             (setq e (ssname s (setq i (1- i))))
  5.             (if (entmake (list '(0 . "CIRCLE") (assoc 10 (entget e)) '(40 . 0.2))) (entdel e))
  6.         )
  7.     )
  8.     (princ)
  9. )
  10. (defun c:c2p ( / e i s )
  11.     (if (setq s (ssget "_:L" '((0 . "CIRCLE"))))
  12.         (repeat (setq i (sslength s))
  13.             (setq e (ssname s (setq i (1- i))))
  14.             (if (entmake (list '(0 . "POINT") (assoc 10 (entget e)))) (entdel e))
  15.         )
  16.     )
  17.     (princ)
  18. )

Compatible with Points & Circles in WCS only.

pedroantonio

  • Guest
Re: Help : point to circle & circle to point lisp
« Reply #3 on: April 05, 2017, 02:36:17 PM »
Thank you  :-D

ChrisCarlson

  • Guest
Re: Help : point to circle & circle to point lisp
« Reply #4 on: April 05, 2017, 04:59:40 PM »
Hi i am using this code to convert points to circle and circlew to points
The problem is When i run this code change all the points of my drawing to circles or all my circles to points.

I want give me the option to select the circles or the points , and the change only the selected points or circles.

Can any on help.

Thanks

Code - Auto/Visual Lisp: [Select]
  1. (defun c:P2C ()
  2. (command "setvar" "clayer" "0")
  3. (COMMAND "_layer" "_m" "layer 1" "_c" "10" "" "")
  4. (setq sset (ssget "_X" '((0 . "POINT"))) i 0)
  5. (if sset
  6.   (repeat (sslength sset)    
  7.     (setq ent (ssname sset i))
  8.     (entmake
  9.       (list
  10.         (cons 0 "CIRCLE")
  11.         (cons 10 (cdr (assoc 10 (entget ent))))
  12.         (cons 40 0.2) ;circle size, change the 10.0 to whatever you want
  13.       )
  14.     )
  15.     (entdel ent)
  16.     (setq i (1+ i))
  17.   )
  18. )
  19.  (setvar 'pdmode 0)
  20.  
  21. )
  22.  
  23. (defun C:C2P (/ ss)
  24. (command "setvar" "clayer" "0")
  25. (COMMAND "_layer" "_m" "layer 1" "_c" "10" "" "")
  26. (defun MakePoint (dxfpt)
  27. (entmakex (list '(0 . "POINT")
  28. ;(cons 8 "0")   ; layer name here
  29. dxfpt ))
  30. )
  31. (setq ss (ssget "_X" '((0 . "CIRCLE"))))
  32. (function (lambda (x) (MakePoint (assoc 10 (entget x)))
  33. (vla-delete (vlax-ename->vla-object x))
  34. )
  35. )
  36. )
  37. )
  38.  

You keep forgetting to include attribution in your routines....

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-replace-circle-into-one-single-point/td-p/2650457