明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2026|回复: 5

[函数] 求获取所选图元的最外形尺寸坐标值程序

[复制链接]
发表于 2011-2-13 22:08 | 显示全部楼层 |阅读模式
大家好,我想用LISP编写一个获取所选图元的最外形尺寸坐标值,在网上查了,用vla-Getboundingbox命令可得,但是编写出来怎么都出错。对象类型不对,搞不懂,后来再网上去下载别人写好的,还是不行,结果就好像是将原来的图形复制了一个一样,还是没出来坐标值,我给你们看看下面的程序,不能用啊,你们现在有人用这功能的程序没,给我发一个,谢谢,请高手帮忙写一个也可以,我用的是CAD2004中文版。
如果有的请发送一个到我的邮箱里,lvdezhi886@163.com  谢谢


(defun c:test()
;com init
(vl-load-com)
;call the directory common dialog by shell,then get the directory path
(setq objSH (vlax-create-object "Shell.Application"))
(setq dir (vlax-invoke-method objSH ’BrowseForFolder 0 "Select a forlder:" 1))
(setq msg (vl-catch-all-apply
           ’(lambda ()
             (setq dir (vlax-get-property dir ’self))
             (setq path (vlax-get-property dir ’path))
            )
          )
)
(if (vl-catch-all-error-p msg) (setq path nil))
(if path (setq dir (strcat path "\\")) (progn (princ "get directory path failure")(exit)))
;;get the list of all dwgfilename
(setq dwglist (vl-directory-files dir "*.dwg" 1))
   
;iter
(setq len (length dwglist))
(setq i -1)
(setq ybuf nil)
(repeat len
  (setq dwgpath (strcat dir (nth (setq i (1+ i)) dwglist)))
  ;insert dwg by block
  (command "_.insert" dwgpath (list 0 0 0) "" "" "")
  (setq ent (entlast))
  (vla-getboundingbox (vlax-ename-&gt vla-object ent) ’minpoint ’maxpoint)
  (setq pt1 (vlax-safearray-&gt list minpoint)
        pt2 (vlax-safearray-&gt list maxpoint)
;here,you can calc perfect coordinates for your insert dwg
        x1  (car pt1)
        y1  (cadr pt1)
        y2  (cadr pt2)
        h   (- y2 y1)
  )
  (if (= nil ybuf)
    (progn
      (setq ybuf (+ y2 (* h 1.1)))
    )
    (progn
      (setq pt2 (list x1 ybuf))
      (setq ybuf (+ ybuf (* h 1.1)))
      (command "_.move" ent "" pt1 pt2)
      
    )
  )
  
  (command "_.explode" ent)
);end iter
)

如果有的请发送一个到我的邮箱里,lvdezhi886@163.com  谢谢

发表于 2011-2-13 22:31 | 显示全部楼层
游客,本帖隐藏的内容需要发帖数高于 5 才可浏览,你当前发帖数只有 0
发表于 2011-2-13 22:33 | 显示全部楼层
先試這個看看

  1. (setq pt1 (vlax-safearray-&gt list minpoint)
  2.         pt2 (vlax-safearray-&gt list maxpoint)
  3. ==>
  4. (setq pt1 (vlax-safearray->list minpoint)
  5.         pt2 (vlax-safearray->list maxpoint)

发表于 2011-2-23 13:02 | 显示全部楼层
ZZXXQQ 发表于 2011-2-13 22:31
[/post]

这个只能选单个图元,怎么实现框选后把所有图元的最外边找出来啊。
发表于 2011-2-23 13:44 | 显示全部楼层
框选后 ....
调用 acet-geom-ss-extents
发表于 2013-1-11 23:29 | 显示全部楼层
我也想知道这个问题的解决办法
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-5 08:15 , Processed in 0.322923 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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