PDA

View Full Version : Move an attirbute within a block



ccowgill
2007-03-21, 03:31 PM
This may not even be necessary, depending on how multiline attributes function in AutoCAD 2008. I am trying to determine if there is a way to move an attribute to an alternate location if one attribute is not used. I have attached an image of what I am referring to. I would like the quantities line to show up centered in it's box. there currently are 2 attributes in that space, but one is not in use.

abdulhuck
2007-03-22, 10:28 AM
The "position" option in "-attedit" command won't help? Sometimes I used to use grip (better if the font is middle aligned) and use the geometrical calculator ('cal) with the expression (int+int)/2.

Regards,
Abdul Huck

ccowgill
2007-03-22, 04:07 PM
do you have an example. What i would like to use is a reactor that fires when the attribute editor is run that checks to see if both have information and adjusts it if they dont, but if later the text is placed in the other line I would like it to move the text back.

ccowgill
2007-03-23, 02:12 PM
What is the Vl function to modify the attribute in this way. Because I am using the reactor, I cant just use the simple command version of -ATTEDIT.

I have attached what I have, if I run (sdc) on it's own it works, but of course with reactors, command doesnt work. If someone could help point me in the right direction, I would appreciate it.


;; Check if SheetDescript_Reactor is loaded in the task otherwise load it ( Do NOT load a reactor more than once )
(if (not SheetDescript_Reactor)
(setq SheetDescript_Reactor
(vlr-command-reactor
nil
'((:vlr-commandended . My_SheetDescript_Command))
)
)
()
;; The reactor is already loaded
)
;;; Function used as Callbacks when the event fires / reactor triggers
(defun My_SheetDescript_Command (In_ReactorName In_Command /)
;(PRIN1 (car In_Command )) ;; <-- Remove this line, it shows all incomming command
;; Check if incomming command is Insert, Pasteclip or Dropgeom
(if
(or
(= (car In_Command) "EATTEDIT")
(= (car In_Command) "DDEDIT")
) ;END OR
;; Then check if the last selected object is TBL13
(SDC)
;; Run the already loaded function BN
;; The last object was not TBL13
()
;; The last command was not EATTEDIT OR DDEDIT
) ;END IF
(princ)
) ;END DEFUN
;|;; How to remove the Reactor :
(vlr-remove SheetDescript_Reactor )
;;; How to clear the place holder :
(setq My_SheetDescript_Command nil )
|;
(defun SDC (/) ;ss Ent EntData Att tmpList Val)
(setq ss (ssget "_x" '((0 . "insert") (2 . "TBL12,TBL13,TBL14"))))
(if (/= ss nil)
(progn
(setq Ent (ssname ss 0))
(setq EntData (entget Ent))
(if
(and
(= (cdr (assoc 0 EntData)) "INSERT")
(= (strcase (cdr (assoc 2 EntData))) "TBL14")
(not
(foreach Att (vlax-invoke
(vlax-ename->vla-object Ent)
'GetAttributes
)
(if (= (vla-get-TagString Att) "SHEETDESCRIPTIONLINE1")
(setq Att2 (vlax-vla-object->ename Att))
) ;end if
(if (= (vla-get-TagString Att) "SHEETDESCRIPTIONLINE2")
(progn
(setq tmpList (cons Att (vla-get-TextString Att))
val (cdr tmplist)
) ;end setq
(if (= val "")
(command "-attedit" "Y"
"TBL*" "SHEETDESCRIPTIONLINE1"
"" Att2
"p" "34.5795,6.55"
""
)
(command "-attedit" "Y"
"TBL*" "SHEETDESCRIPTIONLINE1"
"" Att2
"p" "34.45,6.55"
""
)
) ;end if
) ;end progn
) ;end if
) ;end foreach
) ;END NOT
) ;END AND
(vla-put-TextString (car tmpList) VAL)
(vla-Update (car tmpList))
) ;end if
) ;end progn
) ;end if
) ;END DEFUN

ccowgill
2007-03-27, 06:34 PM
problem solved:



(if (= (vla-get-TagString Att) "SHEETDESCRIPTIONLINE1")
(setq Att2 Att)
) ;end if
(if (= (vla-get-TagString Att) "SHEETDESCRIPTIONLINE2")
(progn
(setq tmpList (cons Att (vla-get-TextString Att))
val (cdr tmplist)
) ;end setq
(if (= val "")
(vla-put-textalignmentpoint att2 (vlax-3d-point '(34.5795 6.55 0)))
(vla-put-textalignmentpoint att2 (vlax-3d-point '(34.45 6.55 0)))
) ;end if
) ;end progn
) ;end if