这是我目前正在使用的创建MleaderStyle的代码
- ;; original code by VVA
- (defun Create_MleaderStyle (mleaderstylename
- MldScale
- /
- ; acaddoc
- ; mldrdict
- ; newldrstyle
- ;objcolor
- )
- (vl-load-com)
- (setq acadobj (vlax-get-acad-object)
- acaddoc (vla-get-activedocument acadobj)
- mldrdict (vla-item (vla-get-dictionaries acaddoc) "ACAD_MLEADERSTYLE")
- ) ;_ end of setq
- (setq newldrstyle (vlax-invoke-method mldrdict 'addobject mleaderstylename "AcDbMLeaderStyle"
- ) ;_ end of vlax-invoke-method
- ) ;_ end of setq
- (setq objcolor (vla-getinterfaceobject acadobj (strcat "AutoCAD.AcCmColor." (substr (getvar "acadver") 1 2)) ;_ end of strcat
- ) ;_ end of vla-getinterfaceobject [b][color="red"];;what is vla-getinerfaceobject, and what am i retreiving?[/color][/b]
- ) ;_ end of setq
- (vla-put-colorindex objcolor 2)
- (vla-put-textcolor newldrstyle objcolor) [color="red"][b];;howcome I have to set color this way instead of the alternate in code below[/b][/color]
- (vla-put-colorindex objcolor 0)
- (vla-put-leaderlinecolor newldrstyle objcolor)
- (foreach item
- (list
-
- '("AlignSpace" 0.18)
- '("Annotative" 0)
- '("ArrowSize" 0.125)
- ;'("ArrowSymbol" "")
- '("BitFlags" 0)
- ;'("Block" "")
- '("BlockConnectionType" 0)
- '("BlockRotation" 0.0)
- '("BlockScale" 1.0)
- '("BreakSize" 0.125)
- '("ContentType" 2) ;mtext
- '("Description" "")
- '("DoglegLength" 0.125)
- '("DrawLeaderOrderType" 0)
- '("DrawMLeaderOrderType" 1)
- '("EnableBlockRotation" -1)
- '("EnableBlockScale" -1)
- '("EnableDogleg" -1)
- '("EnableFrameText" 0)
- '("EnableLanding" -1)
- '("FirstSegmentAngleConstraint" 0)
- '("LandingGap" 0.09)
- '("LeaderLineType" 1)
- '("LeaderLineTypeId" "ByBlock")
- '("LeaderLineWeight" -2)
- '("MaxLeaderSegmentsPoints" 0)
- (list "ScaleFactor" MldScale)
- '("SecondSegmentAngleConstraint" 0)
- '("TextAlignmentType" 0)
- '("TextAngleType" 0)
- '("TextAttachmentDirection" 0)
- '("TextBottomAttachmentType" 0)
- '("TextHeight" 0.09375)
- '("TextLeftAttachmentType" 1)
- '("TextRightAttachmentType" 1)
- '("TextString" "")
- '("TextStyle" "StyleName") ;need to add check for existing
- '("TextTopAttachmentType" 0)
- ) ;_ end of list
- (vlax-put newldrstyle (car item) (cadr item))
- ) ;_ end of foreach
- newldrstyle
- ) ;_ end of defun
怎么会这样?我试过了,它不起作用。
- (vlax-put-property (vlax-get-property newldrstyle 'Textcolor) 'ColorIndex 5)
|