Author Topic: 1.)arrangement list and 2.)how to get block biggest circle on block  (Read 390 times)

0 Members and 1 Guest are viewing this topic.

masao

  • Newt
  • Posts: 98
hi~

1.)

how can i get this result?

select LWPOLYLINE arrangement it.

if x and y overlapping remove it.

2.)

if i use (ssget) select some INSERT(block and has some circle on it) , how can i get biggest circle and coordinate on block?

dwg has block

-------------------------------------Q1 code---------------------------------------------------

Code - Auto/Visual Lisp: [Select]
  1. (defun c:get_list()
  2.  
  3. (setq osm (getvar "osmode"))
  4.  
  5. (setq ss (ssget '((0 . "LWPOLYLINE"))))
  6.  
  7. (if ss
  8.  
  9.  
  10. (setq i 0)
  11.  
  12. (setq pt_list '())
  13.  
  14.  
  15. (setq obj (vlax-ename->vla-object (ssname ss i)))
  16.  
  17. (vla-GetBoundingBox obj 'p1 'p2)
  18.  
  19. (setq pt_list (cons (list (get_midpt (vlax-safearray->list p1) (vlax-safearray->list p2)) obj (vlax-safearray->list p1) (vlax-safearray->list p2)) pt_list))
  20.  
  21. (setq i (+ i 1))
  22.  
  23. );repeat
  24.  
  25. (setq pt_list (vl-sort pt_list (function (lambda (e1 e2) (if (or (equal (cadr (car e1)) (cadr (car e2)) 1e1) (< (- (abs (- (cadr (car e1)) (cadr (car e2)) )) (abs (- (cadr (caddr e1)) (cadr (car e1)) )) (abs (- (cadr (caddr e2)) (cadr (car e2)) )) ) 0) ) (< (car (car e1)) (car (car e2))) (> (cadr (car e1)) (cadr (car e2))) )))))
  26.  
  27. (setq k 1)
  28.  
  29. (foreach pt pt_list
  30.  
  31. (setq a3wp1 (caddr pt))
  32.  
  33. (setq a3wp2 (cadddr pt))
  34.  
  35. (setvar "osmode" 0)
  36.  
  37. (command "rectangle" a3wp1 a3wp2)
  38.  
  39. (setq obj (vlax-ename->vla-object (entlast)))
  40.  
  41. (vlax-put obj 'color k)
  42.  
  43. (setq k (+ k 1))
  44.  
  45. );foreach
  46.  
  47. );progn
  48.  
  49. );if
  50.  
  51. (setvar "osmode" osm)
  52.  
  53. )
  54.  
  55.  
  56.  
  57. (defun get_midpt(pt1 pt2)
  58.  (setq mx (/ (+ (car pt1) (car pt2)) 2))
  59.  (setq my (/ (+ (cadr pt1) (cadr pt2)) 2))
  60.  (list mx my)
  61. )

edit @kerry : add AutoLisp code formatting tag [code=cadlisp-7]
« Last Edit: July 12, 2024, 09:03:32 AM by masao »