Author Topic: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary  (Read 4505 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
When I dump the mleaderstyles object, I see that it contains an AddObject method.  I assume this is the method to create a new mleaderstyle:
Quote
(vlax-dump-object mlstyles T)
; IAcadDictionary: A container object for storing and retrieving objects
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 0000000140db8ca0>
;   Count (RO) = 1
;   Document (RO) = #<VLA-OBJECT IAcadDocument 0000000045a0ea80>
;   Handle (RO) = "188B"
;   HasExtensionDictionary (RO) = 0
;   Name = "ACAD_MLEADERSTYLE"
;   ObjectID (RO) = 451
;   ObjectID32 (RO) = 451
;   ObjectName (RO) = "AcDbDictionary"
;   OwnerID (RO) = 450
;   OwnerID32 (RO) = 450
; Methods supported:
;   AddObject (2)
;   AddXRecord (1)
;   Delete ()
;   GetExtensionDictionary ()
;   GetName (1)
;   GetObject (1)
;   GetXData (3)
;   Item (1)
;   Remove (1)
;   Rename (2)
;   Replace (2)
;   SetXData (2)
T

When I try to use this method I get the following:
Quote
(vla-addobject mlstyles "SheetNote")
too few actual parameters
_1$ (vla-addobject mlstyles "SheetNote" 1)
; error: Automation Error. AcRxClassName entry is not in the system registry
_2$ (vla-addobject mlstyles "SheetNote" 0)
; error: Automation Error. AcRxClassName entry is not in the system registry
_3$

The help on vla-addobject doesn't include a signature for mleaderstyle.

I am certainly doing something wrong.  How do I create a new mleaderstyle?

Mike

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #1 on: August 07, 2012, 10:59:27 AM »
I use vlax-invoke like so (no error checking)

Code - Auto/Visual Lisp: [Select]
  1.   (vlax-ename->vla-object
  2.     (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")))
  3.   )
  4.   'addobject
  5.   "test"
  6.   "AcDbMLeaderStyle"
  7. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #2 on: August 07, 2012, 11:12:26 AM »
Yep, the AddObject method's 2nd argument needs to be the ObjectName of the new object. Personally I use the entmakex & dictadd for these things. But as ronjonp's shown it is possible through ActiveX as well.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

mkweaver

  • Bull Frog
  • Posts: 352
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #3 on: August 07, 2012, 02:08:16 PM »
Thanks, guys.  That gets me what I needed.

Mike

velasquez

  • Newt
  • Posts: 195
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #4 on: June 02, 2014, 05:36:22 PM »
I could not get your code to work with AutoCAD 2010 below.
Can you tell me what changes with this version?
Thanks
I use vlax-invoke like so (no error checking)

Code - Auto/Visual Lisp: [Select]
  1.   (vlax-ename->vla-object
  2.     (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")))
  3.   )
  4.   'addobject
  5.   "test"
  6.   "AcDbMLeaderStyle"
  7. )

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #5 on: June 03, 2014, 09:39:56 AM »
I could not get your code to work with AutoCAD 2010 below.
Can you tell me what changes with this version?
Thanks
I use vlax-invoke like so (no error checking)

Code - Auto/Visual Lisp: [Select]
  1.   (vlax-ename->vla-object
  2.     (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")))
  3.   )
  4.   'addobject
  5.   "test"
  6.   "AcDbMLeaderStyle"
  7. )


Are you getting any errors? Unfortunately I do not have access to AutoCAD 2010 but can confirm this code works in AutoCAD 2015.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #6 on: June 03, 2014, 12:16:41 PM »
Honestly, this can add the style, but setting all of the properties is difficult to impossible in some cases. What we did was create the styles we needed in a drawing and insert it as a block when needed. It's fast and it works.

velasquez

  • Newt
  • Posts: 195
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #7 on: June 03, 2014, 02:03:45 PM »
I could not get your code to work with AutoCAD 2010 below.
Can you tell me what changes with this version?
Thanks
I use vlax-invoke like so (no error checking)

Code - Auto/Visual Lisp: [Select]
  1.   (vlax-ename->vla-object
  2.     (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")))
  3.   )
  4.   'addobject
  5.   "test"
  6.   "AcDbMLeaderStyle"
  7. )


Are you getting any errors? Unfortunately I do not have access to AutoCAD 2010 but can confirm this code works in AutoCAD 2015.

Yes I do I get the error below:
"; Error: AutoCAD.Application: AcRxClassName entry is not in the system registry"
  In larger that 2010 versions the code works fine.

Thanks


ronjonp

  • Needs a day job
  • Posts: 7529

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #9 on: June 03, 2014, 05:30:14 PM »
Looks like it is a bug:
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Help-Error-creating-mleaderstyle/td-p/3050426
I knew there was a reason we went with the block approach, I just couldn't remember all of the details.

velasquez

  • Newt
  • Posts: 195
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #10 on: June 03, 2014, 05:46:04 PM »
Thanks or all the answers.
I will work with the code below.

Code: [Select]
(dictadd DIC "MyLeaderStyle" OBJ)

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #11 on: June 03, 2014, 06:27:01 PM »
Thanks or all the answers.
I will work with the code below.

Code: [Select]
(dictadd DIC "MyLeaderStyle" OBJ)
Going through my notes, be very careful with this one, it can cause data corruption and/or application crashes under certain circumstances. I didn't take as detailed notes as I should have, but I know one of the circumstances was if you use any LISP Reactors. I know there were other things we found that caused problems with this one as well. It is possible that the problem have been corrected in 2014 or newer, as I haven't tried with these versions, but I know 2013 and older had these issues.

velasquez

  • Newt
  • Posts: 195
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #12 on: June 04, 2014, 07:55:49 AM »
Thanks or all the answers.
I will work with the code below.

Code: [Select]
(dictadd DIC "MyLeaderStyle" OBJ)
Going through my notes, be very careful with this one, it can cause data corruption and/or application crashes under certain circumstances. I didn't take as detailed notes as I should have, but I know one of the circumstances was if you use any LISP Reactors. I know there were other things we found that caused problems with this one as well. It is possible that the problem have been corrected in 2014 or newer, as I haven't tried with these versions, but I know 2013 and older had these issues.

Thanks cmwade77,
Thanks cmwade77,
I will study it more calmly before working.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: How do I add a new MLeaderStyle to the Acad_mleaderstyle dictionary
« Reply #13 on: June 04, 2014, 07:21:58 PM »
Yes, it was a very tricky one for us here. In the end, blocks were more efficient.