我想要一个自定义设置会自动创建新的维度样式的autolisp例程。我知道可以将尺寸样式从一个图纸复制到另一张图,但是每次都必须这样做是乏味和耗时的。
我已经编辑了我最常用样式的变量列表,但理想情况下,我希望能够从此列表中添加或删除变量。
手动执行此操作的过程是在命令行中设置每个变量,然后使用" -dimstyle save"命令使用自定义名称保存。我试图自己解决这个项目,但是在Autolisp中相对没有经验,我很快意识到我没有足够的知识来正确地做到这一点。
这是为我创建大多数新样式重要的变量列表:
DIMALTD 4
DIMAPOST [null]
DIMALTF 1
DIMALTTD 4
DIMALTU 4
DIMADEC 1
DIMAZIN 0
DIMARCSYM 1
DIMBLK ClosedFilled
DIMBLK1 ClosedFilled
DIMBLK2 ClosedFilled
DIMASZ 1
DIMCEN 0
DIMCLRD 3
DIMDLE 0
DIMLTYPE BYBLOCK
DIMLWD -2
DIMDLI 4
DIMLTEX1 BYBLOCK
DIMLTEX2 BYBLOCK
DIMCLRE 3
DIMEXE 0.5
DIMLWE -2
DIMEXO 0.75
DIMFRAC 0
DIMJOGANG 45
DIMLDRBLK ClosedFilled
DIMLUNIT 5
DIMSCALE 1
DIMRND 0
DIMSAH Off
DIMCLRT 3
DIMTXT 1.5
DIMTIH On
DIMGAP 0.1
DIMTOH On
DIMTAD 0
DIMTXSTY Standard
DIMTM 0
DIMTP 0
DIMTFAC 1
DIMTZIN 0
DIMZIN 0
尝试使用此代码:
(defun C:Test ( / *error* ThisDrawing dimstyles style )
(defun *error* ( msg / )
(if (not (null msg ) ) (progn (princ "nC:Test:*error*: " ) (princ msg ) (princ "n") ) )
)
(setvar "DIMALTD" 4 )
(setvar "DIMALTF" 1 )
(setvar "DIMBLK" "_DOTSMALL" ) ; more You can find for example here http://forums.augi.com/showthread.php?9852-Setting-DIMLDRBLK
(setvar "DIMLTYPE" "BYBLOCK" )
(setvar "DIMEXO" 0.75)
(setq ThisDrawing (vla-get-activedocument (vlax-get-acad-object) ) )
(setq dimstyles (vlax-get-property ThisDrawing 'DimStyles ) )
(setq style (vlax-invoke-method dimstyles 'Add "TestStyle" ) )
(vlax-invoke-method style 'CopyFrom ThisDrawing )
)
谢谢,CAD开发人员。那让我开始了。这是我最终使用的代码。AutoCAD不喜欢文本值变量,所以我只是将它们删除,因为它们对我并不重要。
;automatically create new dimension style
(defun c:jeff ()
(setvar "DIMALTD" 4)
(setvar "DIMALTF" 1)
(setvar "DIMALTTD" 4)
(setvar "DIMALTU" 4)
(setvar "DIMADEC" 1)
(setvar "DIMAZIN" 0)
(setvar "DIMARCSYM" 1)
(setvar "DIMASZ" 1)
(setvar "DIMCEN" 0)
(setvar "DIMCLRD" 3)
(setvar "DIMDLE" 0)
(setvar "DIMLWD" -2)
(setvar "DIMDLI" 4)
(setvar "DIMCLRE" 3)
(setvar "DIMEXE" 0.5)
(setvar "DIMLWE" -2)
(setvar "DIMEXO" 0.75)
(setvar "DIMFRAC" 0)
(setvar "DIMLUNIT" 5)
(setvar "DIMSCALE" 1)
(setvar "DIMRND" 0)
(setvar "DIMCLRT" 3)
(setvar "DIMTXT" 1.5)
(setvar "DIMGAP" 0.1)
(setvar "DIMTAD" 0)
(setvar "DIMTM" 0)
(setvar "DIMTP" 0)
(setvar "DIMTFAC" 1)
(setvar "DIMTZIN" 0)
(setvar "DIMZIN" 0)
(command "dimstyle" "s" "Jeff")
(princ)
)