Author Topic: Access attribute in mleader?  (Read 1887 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
Access attribute in mleader?
« on: March 26, 2009, 10:43:53 AM »
I need to convert a bunch of qleader/tag (attributed blocks) to multileaders.  I can deal with the qleader and the attributed block, but can't see a way to get to the attribute in the block that is associated with the multi-leader.

assoc 340 on the mleader entity list gives me a block_record which seems to contain all of the block insertions for mleaders of the same style, but I can't see an easy way to identify which of those block insertions is associated with the original mleader.

I suppose I could sort the block insertions by distance to the last point of my mleader then take the closest one, but that seems a bit convoluted.

Any suggestions would be appreciated.

Mike

ronjonp

  • Needs a day job
  • Posts: 7535
Re: Access attribute in mleader?
« Reply #1 on: March 26, 2009, 10:47:27 AM »
Do you have a sample drawing?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

mkweaver

  • Bull Frog
  • Posts: 352
Re: Access attribute in mleader?
« Reply #2 on: March 26, 2009, 11:34:52 AM »
Do you have a sample drawing?

Drawing attached.  Proof of concept code (still un-proven), below:
Code: [Select]
(defun c:tl2ml (/) ;Tagged Leader 2 MultiLeader
  (setq
    entLeader   (entsel "\nSelect Leader: ")
    QLeaderPoints (mapcar
    (function
      (lambda (pair)
(cdr pair)
      )
    )
    (vl-remove-if-not
      (function
(lambda (pair)
  (= 10 (car pair))
)
      )
      (setq qlelist (entget (car entleader)))
    )
  )
    temp   (entdel (car entleader))
    entTag   (nentselp (last qleaderpoints))
    objTag   (vlax-ename->vla-object (car enttag))
    MLeaderPoints (if (= "LEADER" (cdr (assoc 0 qlelist)))
    qleaderpoints
    (remove-n 1 QLeaderPoints)
  )
    ptlist   (vlax-make-safearray
    vlax-vbdouble
    (cons 0 (1- (length (apply 'append mleaderpoints))))
  )
    ActSpace   (if (= 0 (getvar "cvport"))
    (vla-get-paperspace
      (vla-get-activedocument (vlax-get-acad-object))
    )
    (vla-get-modelspace
      (vla-get-activedocument (vlax-get-acad-object))
    )
  )
    ptlist   (vlax-safearray-fill ptlist (apply 'append MLeaderPoints))
    MLObj   (vla-addmleader
    ActSpace
    ptlist
    'LeaderIndex
  )
  )
)

(defun remove-n (n lst / a b)
  (setq a lst)
  (repeat n
    (setq b (cons (car a) b)
  a (cdr a)
    )
  )
  (setq a (cdr a))
  (foreach i b (setq a (cons i a)))
  a
)

Thanks for taking a look at this.

Mike

ronjonp

  • Needs a day job
  • Posts: 7535
Re: Access attribute in mleader?
« Reply #3 on: March 26, 2009, 12:51:21 PM »
Mike,

I'll have to look at this in a bit "real" work beckons...

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Access attribute in mleader?
« Reply #4 on: March 26, 2009, 01:08:38 PM »
Here you go.  Simple example.

Code: [Select]
(
    (lambda (/ sel entdata attobj)
       
        (if (setq sel (entsel))
            (progn
                (setq entdata (entget (car sel) '("*")))
                (setq attobj
                    (vlax-ename->vla-object
                        (cdr
                            (assoc
                                330
                                (reverse entdata)
                            )
                        )
                    )
                )
                (vlax-invoke (vlax-ename->vla-object (car sel)) 'SetBlockAttributeValue (vla-get-ObjectId attobj) "Testing")
            )
        )
    )
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.