Originally Posted by
fixo
I just slightly tweaked this code,
see if this will works
So I tried your code and it works as written. I tried modifying it to suit my needs. I removed two arguments (leader and text color. I added one argument, MLDScale. This creates the MLD style but the scale goes crazy. so I'll input as follows
Code:
(make_mleader_style "test" 10.0)
When I check the mstyle it says the scale factor is 1877221544.0. I have no idea what I'm doing wrong. Here is the modified code
Code:
;; 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