guitarguy1685 发表于 2022-7-5 16:16:43

试图得到这个Mleaderstyl

我在Augi论坛上从Fixo中找到了这个创建MleaderStyle的线程
 
我试图修改它以满足我的需要,但在这个过程中,我把ScaleFactor部分搞砸了。首先,我删除了文本/引线颜色的个参数。我硬编码了它们,因为它们在不同的样式中是相同的。我尝试为scale(MLDScale)添加一个参数。我进入比例因子区域,输入MLDscale。lisp运行并创建MLeaderStyle,但比例为arye。
 
当我进入时
 
(Make_mleader_style "test" 10.0)
 
创建样式,比例为1877221544.0000
 
这是修改后的代码
 
;; original code by VVA
(defun make_mleader_style        (mleaderstylename
                       MLDScale                            ;;added/removed arguments
                       /
                       adoc
                       mldrdict
                       newldrstyle
                       objcolor
                        )
(vl-load-com)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(setq        mldrdict
(vla-item (vla-get-dictionaries adoc) "ACAD_MLEADERSTYLE")
) ;_ end of setq
(setq        newldrstyle
(vlax-invoke
   mldrdict
   'addobject
   mleaderstylename
   "AcDbMLeaderStyle"
) ;_ end of vlax-invoke
) ;_ end of setq
(setq        objcolor (vla-getinterfaceobject
           (vlax-get-acad-object)
           (strcat "AutoCAD.AcCmColor."
                   (substr (getvar "acadver") 1 2)
           ) ;_ end of strcat
       ) ;_ end of vla-getinterfaceobject
) ;_ end of setq                                           ;;this is where I override the colors
(vla-put-colorindex objcolor 2)                     ;;I really don't know what's going on here. i"m trying to understand
(vla-put-textcolor newldrstyle objcolor)
(vla-put-colorindex objcolor 0)
(vla-put-leaderlinecolor newldrstyle objcolor)


(foreach item
   (list
   '("AlignSpace" 4)
   '("ArrowSize" 0.125)
   '("BitFlags" 0)
   '("BlockConnectionType" 1)
   '("BlockRotation" 0.0)
   '("BlockScale" 1.0)
   '("BreakSize" 0.125)
   '("ContentType" 2)                ;mtext
   '("Description" "My Style Description")
   '("DoglegLength" 1.25)
   '("DrawLeaderOrderType" 0)
   '("DrawMLeaderOrderType" 1)
   '("EnableBlockRotation" -1)
   '("EnableBlockScale" -1)
   '("EnableDogleg" -1)
   '("EnableFrameText" 0)
   '("EnableLanding" -1)
   '("FirstSegmentAngleConstraint" 0)
   (list "LandingGap"
           (vla-get-landinggap (vla-item mldrdict "Standard"))
   ) ;_ end of list
   '("LeaderLineType" 1)
   '("LeaderLineTypeId" "ByLayer")
   '("LeaderLineTypeId" "ByLayer")
   '("LeaderLineWeight" -3)
   '("MaxLeaderSegmentsPoints" 2)
   '("ScaleFactor" MLDScale)                         ;;This is where I added the argument MLDScale
   '("SecondSegmentAngleConstraint" 0)
   '("TextAlignmentType" 0)
   '("TextAngleType" 0)
   '("TextHeight" 1.5)
   '("TextLeftAttachmentType" 4) ;original 3
   '("TextRightAttachmentType" 4);original 3
   '("TextString" "Default\\PText")
   '("TextStyle" "STANDARD")
   ) ;_ end of list

   (vlax-put newldrstyle (car item) (cadr item))
) ;_ end of foreach
newldrstyle
) ;_ end of defun

 
我哪里出错了?

Grrr 发表于 2022-7-5 16:34:52

撇号/引号传递变量而不进行评估,
 
所以基本上:
'("ScaleFactor" MLDScale) ;;This is where I added the argument MLDScale
 
就像做:
(list "ScaleFactor" 'MLDScale)
 
所以你实际上必须使用:
(list "ScaleFactor" MLDScale) ;;This is where I added the argument MLDScale

guitarguy1685 发表于 2022-7-5 16:45:22

我想我发现了我的问题。我做了一些调试,注意到在ScaleFactor的行中,在我的手表窗口中,MLDScale从未接受我的论点。
 
所以名单
 
'("ScaleFactor" MLDSCALE)
 
评估为
 
("ScaleFactor" MLDSCALE)
 

 
("ScaleFactor" 10.0)
 
我在控制台中测试了这个
 
_$ (setq test 13.0)
13.0
_$ '("a" test)
("a" TEST)
_$
 
我不知道怎么解决这个问题

BKT 发表于 2022-7-5 16:59:25

你试过Grrr在第2篇文章中展示的内容吗?
 
(list "ScaleFactor" MLDScale)

guitarguy1685 发表于 2022-7-5 17:13:38

我在李的网站上找到了答案。我真是个新手。我以前读过这篇文章,我完全忘记了。我希望我的失败能帮助索蒙·埃利斯。
 
李的撇号
 
我刚刚使用了list函数,它工作得很好。请参阅下面的我的控制台测试
 
_$ (setq test 13.0)
13.0
_$ '("A" TEST)   ;;this evaluates literally
("A" TEST)
_$ (list "a" test);;the list function will evaluate the symbol
("a" 13.0)
_$
 
李-麦克解释得更好。我

guitarguy1685 发表于 2022-7-5 17:28:33

 
DOH!我在回复编辑的时候没有注意到你的回复。你基本上是对的。无论如何,谢谢!
页: [1]
查看完整版本: 试图得到这个Mleaderstyl