AutoCAD 2006 introduces many great enhancements with blocks and the way they are inserted and managed. One of the new features that is part of the updates in AutoCAD 2006 is the ability to set an Attribute so its position is locked and therefore can't be moved using grip editing. The property can be changed through the Properties palette after it has been created through the Attribute Definition dialog box or ATTDEF command. But what if you wanted to update an existing attribute through code or add this functionality to an existing LISP routine that you might have in your tool kit.
I have taken the time to figure out who Autodesk is handling this functionality at the object level. Just like the Dimension Mask (or Fill Color) in AutoCAD 2005/2006, they are using Xdata on the object. Below is a sample set of code that demonstrates how to set and unset the Lock Position behavior on an Attribute Definition.
;; Begin code
;; Written by Lee Ambrosius ([email protected])
;; HyperPics LLC (http://www.hyperpics.com)
;; Created on: 5/12/2005
;; AutoCAD Release: 2006
;; This program allows you to lock the position of an Attribute.
;; Sets the Lock Position behavior
(defun c:SetAttLock()
(setLockPosition
(car (entsel "\nSelect Attribute Definition to set Lock Position: "))
'("AcDbAttr" (1070 . 0) (1070 . 1))
)
)
;; Removes the Lock Position behavior
(defun c:RemoveAttLock()
(setLockPosition
(car (entsel "\nSelect Attribute Definition to remove Lock Position: "))
'("AcDbAttr" (1070 . 0) (1070 . 0))
)
)
;; Example (setLockPosition entityName '("AcDbAttr" (1070 . 0) (1070 . 1))))
(defun setLockPosition (entityName lstValue / entData)
(if (/= entityName nil)
(progn
(setq entData (entget entityName '("AcDbAttr")))
(if (= (cdr (assoc 0 entData)) "ATTDEF")
(progn
(if (/= (assoc -3 entData) nil)
(if (= (nth 0 (cadr (assoc -3 entData))) "AcDbAttr")
(setq entData (subst (cons -3 (list lstValue)) (assoc -3 entData) entData))
(setq entData (append entData (list (list -3 lstValue))))
)
(setq entData (append entData (list (list -3 lstValue))))
)
(entmod entData)
)
)
)
)
(princ)
)
;; End code
Happy coding...
Sincerely,
Lee
"...so its position is locked and therefore can't be moved using -ATTEDIT or grip editing..."
I think an attribute locked can be moved using -ATTEDIT
I´m wrong?
Thanks
Posted by: Ignacio Arrue | Saturday, May 14, 2005 at 07:22 AM
Hmmmm... I thought it had an effect on -ATTEDIT, but apparently it doesn't. So you are correct that it doesn't work with -ATTEDIT and a very good catch.
Posted by: Lee Ambrosius | Saturday, May 14, 2005 at 07:41 AM
i HAVE AN EXISTING BLOCK, I WOULD LIKE TO MAKE IT DYNAMIC BLOCK. I WOULD TO CREATE A ROTATION PARAMETER.
HOW DO YOU GO BY DOING THAT.
Posted by: VAHE BOYAJIAN | Wednesday, May 18, 2005 at 10:00 AM
Related to the metion above "...Just like the Dimension Mask (or Fill Color) in AutoCAD 2005/2006, they are using Xdata on the object...", how to Mask (of Fill Color) an Attribute? Also, "Textmask" function from Express Tools does not work with attributes. Do you have any suggestion?
Posted by: Marcel MAT | Tuesday, January 10, 2006 at 09:42 PM
Hi there.
How can you capture the image?
What program did you use to captue that?
If the program is free, can you send me that?
Otherwise, could you tell me the method?
Thanks in advance.
Posted by: grimeye | Sunday, January 14, 2007 at 07:15 PM
All the images on my website and blog are created using SnagIt! by Techsmith.
Posted by: Lee Ambrosius | Sunday, January 14, 2007 at 10:13 PM