0 Members and 1 Guest are viewing this topic.
(defun c:ML-label (/ MLS LA s) (setq LA (getvar "CLAYER")) (if (not (tblsearch "LAYER" "MYLAYER"))(progn (entmake (list '(0 . "LAYER") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") '(2 . "MYLAYER") '(70 . 0) '(62 . 2) '(6 . "CONTINUOUS") '(290 . 1) '(370 . -3) ) ) )) (command "LAYER" "M" "MYLAYER" "") ; Load all MLstyles by loading a block that has all MLstyles in it: (if (not (tblsearch "BLOCK" "MLstyle"))(command ".insert" "MLstyle=Mleader/Labels-EP" (command))) (setq MLS (getvar "CMLEADERSTYLE")) (setvar "CMLEADERSTYLE" "StyleWithTag"); Make the MLstyle 'StyleWithTag' current (command ".mleader" "L" "H" (getpoint "\nStart arrow: ")) (while (> (getvar "CMDACTIVE") 0)(command pause)) (vl-cmdf ".ddedit" (entlast) "") (setvar "CMLEADERSTYLE" MLS)(setvar "CLAYER" LA); restore variables (princ))
;;---------=={ 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: T if successful, else nil ;;;;------------------------------------------------------------;;(defun LM:SetMLeaderBlockAttributeValue ( mleader tag value / def id ) (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) ) ) ) (if (progn (vlax-for obj def (if (and (eq "AcDbAttributeDefinition" (vla-get-Objectname obj)) (eq (strcase tag) (strcase (vla-get-TagString obj)))) (setq id (vla-get-ObjectID obj)) ) ) id ) (not (vla-SetBlockAttributeValue mleader id value)) ) ));;-----------------------=={ 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 ) (if (setq e (car (entsel "\nSelect MLeader: "))) (LM:SetMLeaderBlockAttributeValue e "TAG1" "Test") ))
(defun UpdateMleaderAttributes ( attList / cnt ss Ent tempList ChangeAtt newEntData ) ; Will update all mleaders whose attribute's tag matches those in the attList argument. ; Call like (UpdateMleaderAttributes '(("DETAIL" . "1")("SHEET" . "S-2.4"))) (setq cnt -1) (if (setq ss (ssget "_x" '((0 . "MULTILEADER")))) (while (setq Ent (ssname ss (setq cnt (1+ cnt)))) (foreach i (entget Ent) (if (and (equal (type (cdr i)) 'ENAME) (setq tempList (assoc (cdr (assoc 2 (entget (cdr i)))) attList)) ) (setq ChangeAtt T) ) (setq newEntData (cons (if (and ChangeAtt (equal (car i) 302) ) (progn (setq ChangeAtt nil) (cons 302 (cdr tempList)) ) i ) newEntData ) ) ) (entmod (reverse newEntData)) (setq newEntData nil) ) ) (princ))
<snip>I wish the enums for vla-get-ContentType and vla-get-ContentBlockType were better documented... I kinda had to make an educated guess...
Members Description kNoneContent = 0 MLeader has no content kBlockContent = 1 MLeader has block content kMTextContent = 2 MLeader has MText content kToleranceContent = 3 MLeader has tolerance content
Quote from: Lee Mac on September 07, 2010, 02:33:34 PM<snip>I wish the enums for vla-get-ContentType and vla-get-ContentBlockType were better documented... I kinda had to make an educated guess... ContentTypeQuoteMembers Description kNoneContent = 0 MLeader has no content kBlockContent = 1 MLeader has block content kMTextContent = 2 MLeader has MText content kToleranceContent = 3 MLeader has tolerance content Didn't find anything in the Arx help about the ContentBlockType.
wow,thanks fellows, that is cool. I need to dig into that object stuff, there are so many functions out there that make live so much easier..Thanks again!Bernd
Quote from: T.Willey on September 07, 2010, 02:47:17 PMQuote from: Lee Mac on September 07, 2010, 02:33:34 PM<snip>I wish the enums for vla-get-ContentType and vla-get-ContentBlockType were better documented... I kinda had to make an educated guess... ContentTypeQuoteMembers Description kNoneContent = 0 MLeader has no content kBlockContent = 1 MLeader has block content kMTextContent = 2 MLeader has MText content kToleranceContent = 3 MLeader has tolerance content Didn't find anything in the Arx help about the ContentBlockType.Thanks for looking it up Tim, appreciated. I take it that is all from the Arx documentation? (glad my guess was right )
Perhaps try something like this:Code: [Select];;---------=={ 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: T if successful, else nil ;;;;------------------------------------------------------------;;(defun LM:SetMLeaderBlockAttributeValue ( mleader tag value / def id ) (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) ) ) ) (if (progn (vlax-for obj def (if (and (eq "AcDbAttributeDefinition" (vla-get-Objectname obj)) (eq (strcase tag) (strcase (vla-get-TagString obj)))) (setq id (vla-get-ObjectID obj)) ) ) id ) (not (vla-SetBlockAttributeValue mleader id value)) ) ));;-----------------------=={ 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 ) (if (setq e (car (entsel "\nSelect MLeader: "))) (LM:SetMLeaderBlockAttributeValue e "TAG1" "Test") ))I wish the enums for vla-get-ContentType and vla-get-ContentBlockType were better documented... I kinda had to make an educated guess...