Need Help Creating MLeader Style Arrowhead Type

Need Help Creating MLeader Style Arrowhead Type

mgorecki
Collaborator Collaborator
73 Views
3 Replies
Message 1 of 4

Need Help Creating MLeader Style Arrowhead Type

mgorecki
Collaborator
Collaborator

Hello,

I have been trying to create 2 MLeader styles.  They're very similar except their arrowheads are different.  The first is the standard "_closed_filled", and the second would use the "_dot".

No matter what I try, it causes an error.

I've tried using vla-put-ArrowheadType, vla-put-ArrowheadBlock, and vla-put-ArrowheadStyle, but none of these will work.

 

(defun CreateMLeaderStyle (dwg_scale / CMS_MLeaderStyles newMleaderStyle CMS_ColorObject)
 (setq mlCounter 0)
 (while (< mlCounter 2)
  (if (= mlCounter 0) (setq newMlStyleName "Test"))
  (if (= mlCounter 1) (setq newMlStyleName "Test_Dot"))
  (if (tblsearch "STYLE" "ROMANS")
   (progn
    (setq CMS_MLeaderStyles (vla-item (vla-get-Dictionaries (vla-get-ActiveDocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE"))
    (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list CMS_MLeaderStyles newMlStyleName)))
     (progn
      (setq newMleaderStyle (vla-AddObject CMS_MLeaderStyles newMlStyleName "AcDbMLeaderStyle"))
      (if (= mlCounter 0)
       (progn
	(vla-put-ArrowSymbol newMleaderStyle "_closed_filled")
	;(vla-put-ArrowheadType newMleaderStyle "_closed_filled")
        (vla-put-ArrowSize newMleaderStyle 4.40)
       )
      )
      (if (= mlCounter 1)
       (progn
	(vla-put-ArrowSymbol newMleaderStyle acMLeaderArrowheadDot)
	;(vla-put-ArrowheadBlock newMleaderStyle 3)
        (vla-put-ArrowSize newMleaderStyle 1.5)
       )
      )
      (vla-put-MaxLeaderSegmentsPoints newMleaderStyle 2)
      (vla-put-EnableDogleg newMleaderStyle 1)
      (vla-put-DogLegLength newMleaderStyle 5.0) ;Landing length
      (vla-put-ScaleFactor newMleaderStyle dwg_scale)
      (vla-put-TextStyle newMleaderStyle "ROMANS")
      (vla-put-TextAngleType newMleaderStyle 1)
      (vla-put-TextBottomAttachmentType newMleaderStyle 0) ;Middle
      (vla-put-TextHeight newMleaderStyle 2.20)
      (vla-put-TextLeftAttachmentType newMleaderStyle 1) ;Middle
      (vla-put-TextRightAttachmentType newMleaderStyle 1) ;Middle
      (vla-put-TextTopAttachmentType newMleaderStyle 0) ;Middle
      (vla-put-LandingGap newMleaderStyle 1.0)
     )
     (princ "\n ** Error: MLeader style already exists")
    )
   )
   (princ "\n ** Error: textstyle does not exist")
  )
  (setq mlCounter (+ mlCounter 1))
 ) ;ends while
 (setvar "cmleaderstyle" "Test")
 (princ)
)

 

I get these:

error: ActiveX Server returned an error: Parameter not optional

error: ActiveX Server returned the error: unknown name: ArrowheadType

error: ActiveX Server returned the error: unknown name: ArrowheadBlock

 

Thanks in advance for any help.

 

0 Likes
74 Views
3 Replies
Replies (3)
Message 2 of 4

mgorecki
Collaborator
Collaborator

Also, I'm using AutoCAD Mechanical 2024 (Vanilla)

0 Likes
Message 3 of 4

komondormrex
Mentor
Mentor

hey,

i think you need not to assign arrow block when it is "_closed_filled" as it is a default arrow block for newly created mleader style, while "_Dot" block should be defined at the moment of creating a style with it.

added.

i've the original routine as follows. 

replaced 

(vla-put-ArrowSymbol newMleaderStyle acMLeaderArrowheadDot)

with, because cannot find constant acMLeaderArrowheadDot in the autocad 

(vla-put-ArrowSymbol newMleaderStyle "_dot")

added mleader and changed its arrowhead block to dot to be sure its in a block collection and run the routine. worked just fine. you also may define _dot block yourself before adding such style.

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

I don't know whether this will be helpful to know, but to elaborate on @komondormrex 's Message 3:

"Closed filled" as a Dimension arrowhead is somehow "constructed on the fly," but it is not a Block like other arrowhead choices.

With a Dimension Style using that default arrowhead, draw a Dimension.  Then look at the offerings of Blocks in the current drawing in the Insert palette.  You will not find the arrowhead listed.  Explode that Dimension, and the arrowhead is left as a 2D Solid object, not as a Block.

Now change the arrowhead choice in the Dimension Style to anything else in the list, and draw a Dimension.  Get into the Insert palette, and you will find that arrowhead's Block listed.  Explode that Dimension, and the arrowhead will be a Block.

So somehow you are going to need to deal with closed-filled arrowheads in some way other than the Block-name-based approach that can be used with other kinds.

Kent Cooper, AIA