Rain0923 发表于 2022-7-5 22:15:13

如何获得矩形中心——Re

我试着编写关于矩形变为圆形的lisp(圆形可以指定大小)
但我不知道怎么写才能得到矩形中心。
有人帮忙吗??谢谢!!

MSasu 发表于 2022-7-5 22:21:31

请检查INTERS功能;使用矩形的角作为参数。
(inters corner1st corner3rd corner2nd corner4th)

Tharwat 发表于 2022-7-5 22:24:52


Removed due to ignorance from the OP

hanhphuc 发表于 2022-7-5 22:30:09

我希望OP能理解简单易懂的代码
简单使用命令PEDIT
 


;;;rectang-> circle
(defun c:test (/ p e r c )
;hanhphuc
(if (and (setq e (car (entsel)))
   (=(cdr (assoc 0 (entget e)))"LWPOLYLINE")
   (vl-cmdf "_.PEDIT" e "fit" "")
   (setq c (entsel "\nPick circle to modify radius.. "))
   (setq p (osnap (cadr c) "_cen"))
   (vl-cmdf "_.PEDIT" e "decurve" "")
   (setq r (getdist p "\nRadius.. "))
   ) ;_ end of and
   (command "_.CIRCLE" p r)
   ) ;_ end of if

(princ)
) ;_ end of defun

Rain0923 发表于 2022-7-5 22:35:33

 
你能给我举个例子吗??

Lee Mac 发表于 2022-7-5 22:42:55

下面是另一个示例,使用多段线顶点的矩形边界框:
(defun c:p2c ( / a b e i l s )
   (if (setq s (ssget "_:L" '((0 . "LWPOLYLINE"))))
       (repeat (setq i (sslength s))
         (setq e (entget (ssname s (setq i (1- i))))
               l (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) e))
               a (apply 'mapcar (cons 'min l))
               b (apply 'mapcar (cons 'max l))
         )
         (if (entmake
                   (append '((0 . "CIRCLE")) (LM:defaultprops e)
                     (list
                           (cons010 (mapcar '/ (mapcar '+ a b) '(2 2)))
                           (cons040 (/ (distance a b) 2))
                           (assoc 210 e)
                     )
                   )
               )
               (entdel (cdr (assoc -1 e)))
         )
       )
   )
   (princ)
)

;; Default Properties-Lee Mac
;; Returns a list of DXF properties for the supplied DXF data,
;; substituting default values for absent DXF groups

(defun LM:defaultprops ( enx )
   (mapcar '(lambda ( x ) (cond ((assoc (car x) enx)) ( x )))
      '(
         (006 . "BYLAYER")
         (008 . "0")
         (039 . 0.0)
         (048 . 1.0)
         (062 . 256)
         (370 . -1)
       )
   )
)

(princ)

Rain0923 发表于 2022-7-5 22:47:01

这是一个很好的选择,可以使用PEDIT,但这个圆圈不能改变大小。
无论如何,我学会了一种新的方法。谢谢!!
 

Rain0923 发表于 2022-7-5 22:49:27

这对我来说是个好榜样。
我最近刚学了lisp,没有人能教我,我试着写同样的lisp,但我没有成功。这对我来说真的很难。
谢谢你的分享。。。。。。
 
 

hanhphuc 发表于 2022-7-5 22:55:26

调用程序->拾取图元圆是多段线->然后再次拾取图元,它将提示您修改半径或osnap
 
如果你想学习编码,我建议你学习Tharwat&Lee的代码
[编辑]我使用PEDIT just bcos你是新手,所以请简化

Rain0923 发表于 2022-7-5 22:58:37

这是真的,我真的能够理解如何使用“PEDIT”来满足我的需要。
谢谢你的建议,我会努力学习更多。
 
 
页: [1] 2
查看完整版本: 如何获得矩形中心——Re