明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1682|回复: 7

[求助]meflying版主,请教了。

[复制链接]
发表于 2004-4-12 15:15:00 | 显示全部楼层 |阅读模式
(defun c:ll (/ pt doc pl att pt2 p block blocks blockref)
(setq pt (getpoint "Enter the insert position:"))
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq blocks (vla-get-blocks doc))
(setq block (vla-add blocks (vlax-3d-point pt) "pp"))
(setq pt2 (polar pt 0 15))
(setq p (vlax-make-safearray vlax-vbdouble '(0 . 3)))
(vlax-safearray-fill
p
(list (car pt) (cadr pt) (car pt2) (cadr pt2))
)
(setq pl (vla-AddLightweightPolyline block p))
(setq att (vla-Addattribute
block
3.5
0
"hello"
(vlax-3d-point '(0 0 0))
"HELLO1"
"hello2"
)
)
(setq blockref (vla-insertblock
(vla-get-ModelSpace doc)
(vlax-3d-point pt)
(vla-get-name block)
1
1
1
0
)
)
(setq
ATT (vlax-safearray->list
(vlax-variant-value
(vla-getattributes BLOCKREF)
)
)
)
(princ)
) 这是您以前编的一个程序,为什么炸开后,属性会跑到原点去? 该怎么改?
发表于 2004-4-12 16:50:00 | 显示全部楼层

因為定義圖塊與插入圖塊是兩回事,圖塊原點都在0,0 所以圖塊內物件以0,0為原點來看你要加入的物件位置,而插入圖塊是以圖塊插入點插入。

看不懂?....8-( 要是我把程序貼上你就會了解!但給點時間給你想想!

 楼主| 发表于 2004-4-13 08:40:00 | 显示全部楼层
是不是就是插入的属性的位置是以图块的插入点作为原点?
发表于 2004-4-13 09:44:00 | 显示全部楼层

錯! 属性的位置是以图块的原点為準(相對位置)!

 楼主| 发表于 2004-4-13 13:45:00 | 显示全部楼层
哦,明白了,可怎么创建一个图块让它打散后,属性的位置不会跑至原点呢?


是不是创建时以原点作为基点,再插入该图块?
 楼主| 发表于 2004-4-13 13:56:00 | 显示全部楼层
(defun c:ll (/ pt doc pl att pt2 p block blocks blockref)
(setq pt (getpoint "Enter the insert position:"))
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq blocks (vla-get-blocks doc))
(setq block (vla-add blocks (vlax-3d-point '(0 0 0)) "pp")) ;;;改了一下
(setq pt2 (polar (list 0 0 0) 0 15)) ;;;改了一下
(setq p (vlax-make-safearray vlax-vbdouble '(0 . 3)))
(vlax-safearray-fill
p
(list (car (list 0 0 0)) (cadr (list 0 0 0)) (car pt2) (cadr pt2));;;改了一下
)
(setq pl (vla-AddLightweightPolyline block p))
(setq att (vla-Addattribute
block
3.5
0
"hello"
(vlax-3d-point '(0 0 0))
"HELLO1"
"hello2"
)
)
(setq blockref (vla-insertblock
(vla-get-ModelSpace doc)
(vlax-3d-point pt)
(vla-get-name block)
1
1
1
0
)
)
(setq
ATT (vlax-safearray->list
(vlax-variant-value
(vla-getattributes BLOCKREF)
)
)
)
(princ)
) 是不是就这样子改?有没有其他更好的方法?
发表于 2004-4-13 14:05:00 | 显示全部楼层
本帖最后由 作者 于 2004-4-13 14:39:28 编辑

(defun CL_LAI (/ PT DOC PL ATT PT2 P BLOCK BLOCKS BLOCKREF)
(setq DOC (vla-get-activedocument (vlax-get-acad-object)))
(if (not (tblsearch "block" "pp"))
(progn
(setq BLOCKS (vla-get-blocks DOC))
(setq PT '(0 0 0))
(setq BLOCK (vla-add BLOCKS (vlax-3d-point PT) "pp"))
(setq PT2 (polar PT 0 15))
(setq P (vlax-make-safearray vlax-vbdouble '(0 . 3)))
(vlax-safearray-fill
P
(list (car PT) (cadr PT) (car PT2) (cadr PT2))
)
(setq PL (vla-addlightweightpolyline BLOCK P))
(setq ATT (vla-addattribute
BLOCK
3.5
0
"hello"
(vlax-3d-point '(0 0 0))
"HELLO BABY!"
"hello2"
)
)
)
)
;;(setq BLOCKREF
(vla-insertblock
(vla-get-modelspace DOC)
(vlax-3d-point (getpoint "\nEnter the insert position: "))
"pp"
1
1
1
0
)
;;)
;|
(setq ATT (vlax-safearray->list
(vlax-variant-value
(vla-getattributes BLOCKREF)
)
)
)|;
(princ)
)
 楼主| 发表于 2004-4-13 14:14:00 | 显示全部楼层
呵呵,我上边是这样子写的嘛


图块原点setq block (vla-add blocks (vlax-3d-point '(0 0 0)) "pp"))


线端点setq pt2 (polar (list 0 0 0) 0 15))


线起点和属性也定义在原点。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-28 00:45 , Processed in 0.166882 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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