明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1728|回复: 4

会跟园变化而变化的园中心线

[复制链接]
发表于 2005-10-31 16:58:00 | 显示全部楼层 |阅读模式
加载CCEN.LSP,用命令CCEN.
 楼主| 发表于 2005-10-31 17:01:00 | 显示全部楼层
加载CCEN.LSP,用命令CCEN
 楼主| 发表于 2005-10-31 17:03:00 | 显示全部楼层

(defun C:CCEN ()
 
  ;(vl-cmdf "-linetype" "c" "mycenter" "" "user.lin" 5,-1,1,-1 "")
  ;(vl-cmdf "-layer" "m" "1" "l" "center" "" "c" "red" "1" "")
  (vl-load-com)
  (setq acadObject (vlax-get-acad-object))
  (setq acadDocument (vla-get-ActiveDocument acadObject))
  (setq mSpace (vla-get-ModelSpace acadDocument))
  (setq util (vla-get-Utility acadDocument))
  (setq lts (vla-get-Linetypes acadDocument))
  ;(setvar "CMDECHO" 0)
  (setq selsets (vla-get-SelectionSets acadDocument))

  (setq i (vla-get-count selsets))
  (while (> i 0)
    (setq sset(vla-item  selsets 0))
    (vla-delete sset)
    (setq i (- i 1))
   )
  (setq sset (vla-add selsets "sset"))
  (vla-SelectOnScreen sset)
  (setq ssetcount (vla-get-count sset))
  (setq obj (vla-item sset (- 1 ssetcount)))
  (setq objname (vla-get-objectname obj))


  (while (and (vla-get-count sset) (/= objname "AcDbCircle") )
    (prompt "所选图素中至少有一非圆的图元,请再试一次,或按 ESC 结束!")
    (vla-clear sset)
    (vla-SelectOnScreen sset)
    (setq ssetcount (vla-get-count sset))
    (setq obj (vla-item sset (- ssetcount 1)))
    (setq objname (vla-get-objectname obj))

  )
  (setq circ_d (vla-get-Radius obj))
  (setq circ_cen (vla-get-center obj))
  (setq pt (vla-PolarPoint util circ_cen 0 (+ 5 circ_d)))
  (setq line (vla-addline mspace circ_cen pt))
  (load-line-types "CENTER" "acad.lin")
   (vla-put-Linetype line "CENTER")
  (setq lts (/ circ_d 5))
  (vla-put-LinetypeScale line lts)
  (setq
    linearray (vla-ArrayPolar line 4 (/ (* pi 2 (1- 4)) 4) circ_cen)
  )

  (vla-delete sset)
  (setq circleReactor
         (VLR-Object-Reactor
           (list obj)
           "Circle Reactor"
           '((:VLR-modified . mark))
         )
  )

)
(defun load-line-types (line-type file-name / tmp res)
  (if (and (setq tmp (vlax-get-acad-object))
           (setq tmp (vla-get-activedocument tmp))
           (setq tmp (vla-get-linetypes tmp))
      )
      (if (setq res (find-line-type line-type tmp))
      res
      (progn
        (vla-load tmp line-type file-name)
        (if (vla-item tmp line-type)
          (vla-item tmp line-type)
          nil
        )
      )
    )
    nil
  )
)
(defun find-line-type (line-type line-type-collection / res)
  (setq line-type (strcase line-type))
  (vlax-for l-obj line-type-collection
    (if (= (strcase (vla-get-name l-obj)) line-type)
      (setq res l-obj)
    )
  )
  res
)
(defun mark (notifier-object reactor-object parameter-list)
  (vl-load-com)

  (setq circ_d (vla-get-Radius obj))
  (setq circ_cen (vla-get-center obj))
  (setq pt (vla-PolarPoint util circ_cen 0 (+ 5 circ_d)))
  (vla-delete line)
  (setq linesafearray (vlax-variant-value linearray))
  (vla-delete (vlax-safearray-get-element linesafearray 0))
  (vla-delete (vlax-safearray-get-element linesafearray 1))
  (vla-delete (vlax-safearray-get-element linesafearray 2))
  (setq line (vla-addline mspace circ_cen pt))
  (load-line-types "CENTER" "acad.lin")
  (vla-put-Linetype line "CENTER")
  (setq lts (/ circ_d 5))
  (vla-put-LinetypeScale line lts)
  (setq
    linearray (vla-ArrayPolar line 4 (/ (* pi 2 (1- 4)) 4) circ_cen)
  )
)

 楼主| 发表于 2005-10-31 17:05:00 | 显示全部楼层
不知道什么原因,文件传不上来。
 楼主| 发表于 2005-11-1 08:04:00 | 显示全部楼层
压缩后上传

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-23 11:52 , Processed in 0.183113 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表