jasonle215 发表于 2022-7-5 18:48:01

创建块并放置

大家好,
 
我使用的是autocad 2010,我是autolisp新手。我希望你们能帮我解决这个问题(下图)
 

 
我还在学习autolisp,我不知道如何创建块或将现有块插入特定的选定坐标。此外,通过上述问题,您能否演示如何将对象(或块)复制到均匀空间?
非常感谢你!!!

David Bethel 发表于 2022-7-5 19:03:06

这应该是一个开始:
 

(defun c:rectcir (/ x hx y hy e mx xp xd qt sp)

(initget 6)
(setq x (getdist "\nRectangle X Axis <5000>:   "))
(or x (setq x 5000.))
(setq hx (* x 0.5))

(initget 6)
(setq y (getdist "\nRectangler Y Axis <250>:   "))
(or y (setq y 250.))
(setq hy (* y 0.5))

(initget 6)
(setq e (getdist "\nX Axis End Spacer <200>:   "))
(or e (setq e 200.))

(initget 6)
(setq mx (getdist "\nX Axis Max Spaces <450>:   "))
(or mx (setq mx 450.))

;;;CREATE THE BLOCK
(and (not (tblsearch "BLOCK" "CENTER"))
      (entmake (list (cons 0 "BLOCK")(cons 2 "CENTER")(cons 70 0)(list 10 0 0 0)))
      (entmake (list (cons 0 "LINE")(cons 8 "0")(cons 62 5)(cons 10 (list 0 -100 0))(cons 11 (list 0 100 0))))
      (entmake (list (cons 0 "LINE")(cons 8 "0")(cons 62 5)(cons 10 (list 50 -65 0))(cons 11 (list -50 -65 0))))
      (entmake (list (cons 0 "LINE")(cons 8 "0")(cons 62 5)(cons 10 (list 50 65 0))(cons 11 (list -50 65 0))))
      (entmake (list (cons 0 "CIRCLE")(cons 8 "0")(cons 62 1)(cons 10 (list 0 -65 0))(cons 40 20)))
      (entmake (list (cons 0 "CIRCLE")(cons 8 "0")(cons 62 1)(cons 10 (list 0 65 0))(cons 40 20)))
      (entmake (list (cons 0 "ENDBLK")(cons 8 "0"))))

;;;MAKE THE REECTANGLE
(entmake (list (cons 0 "LINE")
                (cons 10 (list (- hx) (- hy) 0))
                (cons 11 (list (- hx) (+ hy) 0))))
(entmake (list (cons 0 "LINE")
                (cons 10 (list (+ hx) (- hy) 0))
                (cons 11 (list (+ hx) (+ hy) 0))))
(entmake (list (cons 0 "LINE")
                (cons 10 (list (- hx) (+ hy) 0))
                (cons 11 (list (+ hx) (+ hy) 0))))
(entmake (list (cons 0 "LINE")
                (cons 10 (list (- hx) (- hy) 0))
                (cons 11 (list (+ hx) (- hy) 0))))

;;;FIND THE INSERT POINT DATA
(setq xp (+ (- hx) e)         ;1st X axis Value
       xd (- x e e)            ;Total X axis distance
       qt (1+ (fix (/ xd mx)))   ;Qty of spaces
       sp (/ xd qt))             ;X axis spacing

;;;CREATE THE INSERTS
(repeat (1+ qt)
   (entmake (list (cons 0 "INSERT")(cons 2 "CENTER")(list 10 xp 0 0)))
   (setq xp (+ xp sp)))

(prin1))

 
假设:
我把这个街区命名为“中心”
红色圆圈的半径看起来是20(不是直径)
我将矩形居中放置在0,0,0
 
或者:
 
进行第一次插入,然后(命令“_.COPY”(entlast)”。。。
进行第一次插入,然后(命令“.ARRAY”“\u R”(entlast)”。。。
使插入成为单个MINSERT
 
玩得开心-大卫

jasonle215 发表于 2022-7-5 19:23:51

谢谢你,伙计。我试试,然后告诉你

jasonle215 发表于 2022-7-5 19:33:03

它起作用了!!!!非常感谢你

David Bethel 发表于 2022-7-5 19:45:44

不客气
 
-大卫

BIGAL 发表于 2022-7-5 19:51:01

也看看这个帖子
 
http://www.cadtutor.net/forum/showthread.php?93337-帮助拉伸和收缩问题/第2页
页: [1]
查看完整版本: 创建块并放置