比例法(替代
大家好出于缩放目的,我调整了一个例程,让我可以在Z方向缩放选择集。
工作正常,但缺点是它在“参照编辑模式”下不工作。
因为在3D中,很多工作都是在块内完成的,所以我真的在寻找一种不同于这种方法的方法——插入/清除方法。想用vla电话吗?
(defun C:SXYZ (/ SS IP XS YS ZS RA)
(setvar "cmdecho" 0)
(setq SS (ssget)
IP (getpoint "Enter Base point (temp. blockname 'xstemp' will be used :")
) ;_ end of setq
(initget 6)
(setq XS (getreal "Enter X scale factor <1>:"))
(initget 6)
(setq YS (getreal "Enter Y scale factor (default=X):"))
(setq ZS (getreal "Enter Z scale factor (default=X):")
RA (getreal "Enter Rotation angle <0>:")
) ;_ end of setq
(if (= XS NIL)
(setq XS 1)
) ;_ end of if
(if (= YS NIL)
(setq YS XS)
) ;_ end of if
(if (= ZS NIL)
(setq ZS XS)
) ;_ end of if
(if (= RA NIL)
(setq RA 0)
) ;_ end of if
(command
"block""xstemp" IP SS """insert" "xstemp"
IP "xyz" XS YS ZSRA "explode"
"l" "purge""b" "xstemp" "n"
) ;_ end of command
)
(vl-load-com)
(defun c:test()
(if
(setq p2 (getpoint "\nSpecify the insertion point:\n "))
(progn
(setq _blkName "PONTO"
_scaleX 1.0
_scaleY 1.0
_scaleZ 1.0
_rotation 0
) ;_ >setq
(setq vla-obj (vla-insertblock
(
(if (eq (getvar "cvport") 1)
vla-get-paperspace
vla-get-modelspace
) ;_ >if
(vla-get-ActiveDocument
(vlax-get-acad-object)
) ;_ >vla-get-ActiveDocument
)
(vlax-3d-point p2)
_blkName
_scaleX
_scaleY
_scaleZ
_rotation
) ;_ >vla-insertblock
) ;_ >setq
(redraw (entlast) 1)
vla-obj
) ;_ >progn
) ;_ >if
) ;_ >defun
我希望这段代码能帮助你。
顺致敬意,
路易斯·奥古斯托 谢谢你,路易斯!我会试试的。。代码看起来很漂亮
编辑:
:在AutoCAD中没有测试结果
; 错误:自动化错误。文件服务器错误
我认为这一部分
(vlax-3d-点p2)
同样不起作用的是。。
(vla-insertblock
(
(if (eq (getvar "cvport") 1)
vla-get-paperspace
vla-get-modelspace
) ;_ >if
(vla-get-ActiveDocument
(vlax-get-acad-object)
) ;_ >vla-get-ActiveDocument
)
(vlax-3d-point IP)
xstemp ; is this correct? how to call a name by block?
XS
YS
ZS
RA
)
另一个建议是对多个if使用cond
(cond
((= XS NIL)(setq XS 1))
((= YS NIL)(setq YS XS))
((= ZS NIL)(setq ZS XS))
((= RA NIL)(setq RA 0))
)
这就是我使用的参考资料。
我希望它能帮助你。
http://www.afralisp.net/archive/methods/lista/insertblock_method.htm
(defun c:test ()
;---------------{sub function}---------------;
(defun insBlock (
_blkName ;string
_scaleX ;real
_scaleY ;real
_scaleZ ;real
_rotation ;real
/
_blkInsertPoint
*error*
)
(defun *error* (errmsg)
(princ "\nAn error has occurred in the programme.\n ")
(prompt errmsg)
(princ)
) ;_ >defun
(setq thisdrawing
(vla-get-activedocument
(vlax-get-acad-object)
) ;_ >vla-get-activedocument
) ;_ >setq
(setq mspace (vla-get-modelspace thisdrawing))
(setq util (vla-get-utility thisdrawing))
(if (not (tblsearch "BLOCK" _blkName))
(if
(and
(setq filePath (findfile (strcat _blkName ".dwg")))
(progn (command "_.-insert" filePath nil) t)
) ;_ >and
(setq blkFlag t)
(setq blkFlag nil)
) ;_ >if
(setq blkFlag t)
) ;_ >if
(if blkFlag
(progn
(setq _blkInsertPoint (vla-GetPoint util nil "\nInsertion Point: "))
(setq vla-obj
(vla-insertblock
mspace
_blkInsertPoint
_blkName
_scaleX
_scaleY
_scaleZ
_rotation
) ;_ >vla-insertblock
) ;_ >setq
(redraw (entlast) 1)
vla-obj
) ;_ >progn
(alert "Block not found.")
) ;_ >if
) ;_ >defun
;---------------{sub function}---------------;
(setq vla-obj ;get-vlaObject
(insBlock ;call sub function
"blkName" ;your block name
1.0 ;scale x
1.0 ;scale y
1.0 ;scale z
0.0 ;rotation
) ;_ >insBlock
) ;_ >setq
) ;_ >defun
下面是另一个例子:
(defun C:test ( / acDoc AcSpc MyBlockName XS YS ZS Rot insPt BlkRefObj )
(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq AcSpc
(vlax-get
acDoc
(if (= acModelSpace (vla-get-ActiveSpace acDoc))
'ModelSpace
(if (= (vla-get-mSpace acDoc) :vlax-true)
'ModelSpace
'PaperSpace
)
)
)
)'; setq
(setq
MyBlockName "MyBlock"
XS 1.0
YS 1.0
ZS 1.0
Rot 0.0 ; Value in degrees
); setq
(if
(and
(not (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list (vla-get-Blocks acDoc) MyBlockName))))
(setq insPt (getpoint (strcat "\nSpecify \"" MyBlockName "\" insertion point: ")))
)
(setq BlkRefObj (vla-InsertBlock AcSpc (vlax-3D-point insPt) MyBlockName XS YS ZS (* pi (/ Rot 180))))
)
(princ)
);| defun |; (or (vlax-get-acad-object) (vl-load-com)) (princ) AFAIK原始代码的问题是使用了_BLOCK命令,而不是_INSERT命令。创建替代插入代码虽然很有趣,但不会解决OP的问题。 .... 谢谢你们的回复伙计们
Luis很好,但只在“正常”模式下工作,而不是在块编辑器中。
命令:#
命令:**检测到自参考:
1块参考未添加到工作集。
我想。。
-除了操纵“作为块”之外,没有其他方法可以“变形”XYZ
-一种方法作为解决方法。。
1.“refset”=>删除选定项=>
2.“参考关闭”
3、选择SXYZ
4.“refedit”上一个阻止您在其中工作。。
5.“refset”=>添加所选(缩放)。完成。
这正是手动完成的。。。自动化后速度更快
一些好的“refset”添加/删除和Refedit函数。。。正在搜索-参照编辑 你试过使用entmod函数吗?
我想我的知识可能不足以帮助你。
你可以发一张样品图让我们试试吗?
页:
[1]
2