ATTOUT ATTIN with attributes nested in multileaders - AutoLISP / VBA

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey community, I'm trying to automate this process of substituting keynote values that are attributes in blocks used for multileaders using ATTOUT ATTIN and Excel.
I plan on starting the command off with having a selection set made of the multileader style, then ATTOUT the attributes. I imagine this can work with setting an undo mark, exploding the multileaders to expose the attribute block, running ATTOUT, and then undo the explode.
It would be ideal if the ATTOUT output could be copied into an existing workbook, but I have no knowledge of VBA.
From Excel, I have a substitution table setup for the user to substitute values, and another that will act as the ATTIN dataset.
Now here's the trouble I have. I can't do the same undo mark logic and have the ATTIN change stick. The closest code I've come across that selects a multileader and changes an attribute is by Lee Mac, see below.
Any help is appreciated, thank you!
;;---------=={ Set MLeader Block Attribute Value }==----------;; ;; ;; ;; Sets the value of the specified tag for the specified ;; ;; MLeader ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; mleader - ename/VLA-Object MLeader with attributed block ;; ;; tag - Tagstring of the attribute to change ;; ;; value - Value to which attribute will be set ;; ;;------------------------------------------------------------;; ;; Returns: nothing ;; ;;------------------------------------------------------------;; (defun lm:setmleaderblockattributevalue (mleader value / def id exval) (vl-load-com) ;; © Lee Mac 2010 (if (and (eq "AcDbMLeader" (vla-get-objectname (setq mleader (cond ((eq 'vla-object (type mleader)) mleader) ((vlax-ename->vla-object mleader)) ) ) ) ) (= 1 (vla-get-contenttype mleader)) (setq def (lm:itemp (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (vla-get-contentblockname mleader) ) ) ) (vlax-for obj def (if (eq "AcDbAttributeDefinition" (vla-get-objectname obj)) ;; RJP mod to get existing value and add a new value to it (if (and (setq id (vla-get-objectid obj)) (setq exval (vla-getblockattributevalue mleader id)) ) (vla-setblockattributevalue mleader id (vl-princ-to-string (+ value (atof exval)))) ) ) ) ) ) ;;-----------------------=={ Itemp }==------------------------;; ;; ;; ;; Retrieves the item with index 'item' if present in the ;; ;; specified collection, else nil ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; coll - the VLA Collection Object ;; ;; item - the index of the item to be retrieved ;; ;;------------------------------------------------------------;; ;; Returns: the VLA Object at the specified index, else nil ;; ;;------------------------------------------------------------;; (defun lm:itemp (coll item) ;; © Lee Mac 2010 (if (not (vl-catch-all-error-p (setq item (vl-catch-all-apply (function vla-item) (list coll item)))) ) item ) ) (defun c:test (/ e i n ss) (if (and (setq n (getdist "\nEnter increment amount: ")) (setq ss (ssget ":L" '((0 . "multileader")))) ) (repeat (setq i (sslength ss)) (lm:setmleaderblockattributevalue (ssname ss (setq i (1- i))) n) ) ) )