blueshake 发表于 2022-7-6 09:57:06

复制和修剪

大家好
以下代码用于复制受用户定义的圆约束的对象。
我的问题来了。请看图片。
蓝色的是复制自,而绿色的圆圈是用户定义的区域。现在我只想修剪蓝色的。不是绿线。我该怎么做
这感谢您抽出时间阅读本文。
http://www.ikaca.sh.cn/attachment/201010/31/1745_12884871409MUZ.png
 
(defun c:tt(/)
(setq pt (getpoint "\nget the center point."))
(command "_.circle" pt)
(princ (strcat "\ninput the radius of circle"))
(command pause "")       
(setq cir (entlast))
(setq r (cdr (assoc 40 (entget cir))))
(command "copy" "cp")
(setq n 0)
(repeat 180
        (command (polar pt (/(* 2 n pi)180) r))
        (setq n (+ n 1))       
)
(command "" "" pt (getpoint));ok ,finish the choose and copy
;now how to get copied objects. and trim the things outside the circle.
;here I just want to trim the copied objects.


)

David Bethel 发表于 2022-7-6 10:03:41

如果您不使用TRIM命令,有点旧,但这可能是一个起点:
 

;;;Intersection Point Of LINE & CIRCLE
;;;ARG -> LINE ename CIRCLE ename
;;;RETURNS 2D point list or nil
(defun inters_line_circle (le ce / p10 p11 cen rad ppt pds osd ipt p2d)
(setq p2d (lambda (p) (list (car p) (cadr p))))
(and (= (type le) 'ENAME)
      (= (type ce) 'ENAME)
      (= "LINE" (cdr (assoc 0 (entget le))))
      (= "CIRCLE" (cdr (assoc 0 (entget ce))))
      (setq p10 (p2d (cdr (assoc 10 (entget le))))
            p11 (p2d (cdr (assoc 11 (entget le))))
            cen (p2d (cdr (assoc 10 (entget ce))))
            rad (cdr (assoc 40 (entget ce))))
      (cond ((equal p10 p11 1e-14))
            ((equal rad (distance cen p10) 1e-11)
             (setq ipt p10))
            ((equal rad (distance cen p11) 1e-11)
             (setq ipt p11))
            ((setq ppt (inters p10 p11 cen
                               (polar cen (+ (angle p10 p11) (* pi 0.5)) rad) nil))
             (and (setq pds (distance cen ppt))
                  (<= pds rad)
                  (setq osd (sqrt (- (* rad rad) (* pds pds)))
                        ipt (polar ppt (angle ppt p10) osd))))))
ipt)

blueshake 发表于 2022-7-6 10:05:49

我不确定你的要求,但这可能会帮助你或接近你的形象。
 
(defun c:tt(/)
(defun *error* (msg)
        (setvar "osmode" oldOsmode)
)
(setq oldOsmode (getvar "osmode"))
(setvar "OSMODE" 0)
(setq pt (getpoint "\nget the center point."))
(command "_.circle" pt)
(princ (strcat "\ninput the radius of circle"))
(command pause "")                (setq cir (entlast))
(setq r (cdr (assoc 40 (entget cir))))
(command "copy" "cp")
(setq n 0)
(repeat 180
        (command (polar pt (/ (* 2 n pi) 180) r))
        (setq n (+ n 1))       
)
(command "" "" pt pt)
(setvar "pickbox" 5)
(command "_.trim" cir "" "f")
(setq n 0)
(repeat 180
        (command (polar pt (* (/(* 2 n) 180.0) pi) (* r 1.05)))
        (setq n (1+ n))
)
        (command "" "")
;(command "" "" pt (setq ptt (getpoint pt)));ok ,finish the choose and copy
;now how to get copied objects. and trim the things outside the circle.
;here I just want to trim the copied objects.


)
 
塔瓦特

Lee Mac 发表于 2022-7-6 10:11:42

粗略的例子,但应该有助于您的修剪部分。

(defun c:tt (/ pt rad cir all)
(command "_.circle" (setq pt (getpoint "\n Specify the center point."))
                            (setq rad (getdist pt "\n Get Circle Diameter ."))
               )
(setq cir (entlast)
)
(princ "\n Select objects to be trimed")
       (setq all (ssget "_x" '((0 . "SPLINE,LWPOLYLINE,POLYLINE,LINE,CIRCLE"))))
(repeat (sslength all)
(command "_.trim" cir "" all "")
)
      (princ)
)

blueshake 发表于 2022-7-6 10:15:54

大家好
我终于完成了这个计划。
这是代码。
(defun c:Test (/ lastEntity pt ent)
(setq lastEntity (entlast))
(if (or etrim (load "extrim.lsp" nil))
   (if (setq pt (getpoint "\nSpecify center point for circle: "))
   (progn
       (command "_.circle" "_non" pt)
       (while (eq 1 (logand 1 (getvar 'cmdactive))) (command PAUSE))
       (or (eq lastEntity (setq ent (entlast)))
         (etrim ent (polar (cdr (assoc 10 (entget ent))) 0. (1+ (cdr (assoc 40 (entget ent))))))
       )
   )
   )
   (alert "Express Tool \"Extrim\" does not exist!")
)
(princ)
)

Lee Mac 发表于 2022-7-6 10:19:59

这里有一些解释。
1.画一个圆,并给出要放置放大物体的位置。
2.复制圆圈周围的对象,并将其放置在步骤1中设置的位置
3.把圆圈外的东西修剪一下,放大
但我还是搞不懂。当我移动圆时,它无法实时显示圆。这很奇怪。

blueshake 发表于 2022-7-6 10:26:50

我还注意到
我评论的这些代码无法工作
(defun c:tt(/)
(defun *error* (msg)
        (setvar "osmode" oldOsmode)
)
(setq oldOsmode (getvar "osmode"))
(setvar "OSMODE" 0)
(setq pt (getpoint "\nget the center point."))
(command "_.circle" pt)
(princ (strcat "\ninput the radius of circle"))
(command pause "")               
(setq cir (entlast))
(setq r (cdr (assoc 40 (entget cir))))
;(command "_.circle" pt 2*r "")
(setq enlargeCircle (entlast))
(command "_.move" enlargeCircle "" pt (setq ptt (getpoint pt)))
(command "copy" "cp")
(setq n 0)
(repeat 180
        (command (polar pt (/ (* 2 n pi) 180) r))
        (setq n (+ n 1))       
)
(command "" "" pt ptt)
(setvar "pickbox" 5)
(command "_.trim" cir "" "f")
(setq n 0)
(repeat 180
        (command (polar ptt (* (/(* 2 n) 180.0) pi) (* r 1.01)))
        (setq n (1+ n))
)
        (command "" "")
(command "_.scale" "cp")
(setq n 0)
(repeat 180
        (command (polar ptt (/ (* 2 n pi) 180) r))
        (setq n (1+ n))
)
(command "" "" ptt 2 "")
        (command "redarw")
(princ)
;(command "" "" pt (setq ptt (getpoint pt)));ok ,finish the choose and copy
;now how to get copied objects. and trim the things outside the circle.
;here I just want to trim the copied objects.


)
 
它不能像我预期的那样实时绘制圆。

Tharwat 发表于 2022-7-6 10:27:18

我已经完成了详细视图代码。它是用来做工作的图片显示。希望s.b.能改善这一点。tt。lsp

alanjt 发表于 2022-7-6 10:33:14

为什么不以不同的比例创建另一个视口?无需创建多个对象。

blueshake 发表于 2022-7-6 10:38:19

我只想放大蓝色圆圈内的物体@alanjt。以你上述的方式。这能做到吗?你能给我看些东西吗。
谢谢
页: [1] 2
查看完整版本: 复制和修剪