Author Topic: How to get and set values from Attributed Block in Mleader  (Read 2706 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
How to get and set values from Attributed Block in Mleader
« on: October 02, 2015, 03:03:01 PM »
Hello guys .

I stuck in getting inside Mleader object to Get and Set the values of Attributed Block in Mleader according to its Tag strings.

Any one can give any example or how to get the vla-object that represents the Attributed Block inside Mleader ?

Thanks in advanced .

ronjonp

  • Needs a day job
  • Posts: 7533

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Coder

  • Swamp Rat
  • Posts: 827
Re: How to get and set values from Attributed Block in Mleader
« Reply #2 on: October 02, 2015, 03:33:39 PM »
http://www.theswamp.org/index.php?topic=46547.msg515485#msg515485

Thank you ronjonp for your time and post.  :-)

And thank you Lee for the good work.  :-)

cmwade77

  • Swamp Rat
  • Posts: 1449
Re: How to get and set values from Attributed Block in Mleader
« Reply #3 on: October 02, 2015, 06:51:31 PM »
Yes, as usual, Lee's code works wonders.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: How to get and set values from Attributed Block in Mleader
« Reply #4 on: October 03, 2015, 06:30:22 AM »
Thanks guys  :-)

Coder

  • Swamp Rat
  • Posts: 827
Re: How to get and set values from Attributed Block in Mleader
« Reply #5 on: October 03, 2015, 06:39:07 AM »
Hello Lee.

Can you please help me by modifying your function to allow me to get the text string into a field codes to be used in Mtext ?

I tried this but it did not work.

Code - Auto/Visual Lisp: [Select]
  1. (defun getmleaderatts (obj / rtn)
  2.   (if
  3.     (and
  4.       (= "AcDbMLeader" (vla-get-objectname obj))
  5.       (= acblockcontent (vla-get-contenttype obj))
  6.       (eq (vla-get-ContentBlockName obj) "PILE")
  7.     )
  8.      (vlax-for sub
  9.                    (vla-item
  10.                      (vla-get-blocks (vla-get-document obj))
  11.                      (vla-get-contentblockname obj)
  12.                    )
  13.        (if (and (= "AcDbAttributeDefinition" (vla-get-objectname sub))
  14.                 (eq (strcase (vla-get-tagstring sub)) "DIA")
  15.            )
  16.          (setq rtn (strcat "%<\\AcObjProp Object(%<\\_ObjId "
  17.                            (LM:objectid sub)
  18.                            ">%).TextString>%"
  19.                    )
  20.          )
  21.        )
  22.      )
  23.   )
  24.   rtn
  25. )

Code - Auto/Visual Lisp: [Select]
  1. (if (and (setq str (getmleaderatts (vlax-ename->vla-object (car (entsel "\nSelect Mleader with Block PILE :"))
  2.                      )
  3.                    )
  4.          )
  5.          (setq pnt (getpoint "\nInsertion Point :"))
  6.     )
  7.   (vla-addmtext (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
  8.     (vlax-3D-point (trans pnt 1 0))
  9.     0.0
  10.     str
  11.   )
  12. )

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: How to get and set values from Attributed Block in Mleader
« Reply #6 on: October 03, 2015, 11:35:51 AM »
As far as I am aware, this is not possible as a Field expression must reference an ActiveX property and there is no ActiveX property which gives the text content of an MLeader Attribute (this must be obtained using the ActiveX getattributevalue method, as shown in my example in the other thread.

Coder

  • Swamp Rat
  • Posts: 827
Re: How to get and set values from Attributed Block in Mleader
« Reply #7 on: October 03, 2015, 01:15:37 PM »
Thank you Lee for your reply.

I think I need to go back to normal Mleader to be able to link the TextString property in Fields.