Philipp Posted March 29 Share Posted March 29 In electrical floor-plan drawings I use blocks that come with attributes that are 0° when the block is inserted with an angle of 0°. So when the blocks are aligned with a wall that is 271° to 90° every information is readable in the layout. From 91° to 270°, I always have to turn every attribute with 180° and set, for example the Referenzen point of the Text from lower right to upper left. Is there a way to insert the block with an angle that is readable and turn +90° with a lisp that does the turning of the attributes for me? I tried with horizontal aligned text, but that didn't work for me. I'd like to have the option of rotating without changing attributes with rotate command, and with lisp that turns attribute-texts 180° on their spot. In the attachment, there is a dwg that shows one of the blocks I use,the attributes are allwas named and layered the same is in there. example.dwg Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 29 Share Posted March 29 Would a dynamic block help here, insert and set rotation dynamically? Quote Link to comment Share on other sites More sharing options...
Philipp Posted March 30 Author Share Posted March 30 I dont think this could help. If I put an angle to every attribute, I would have many more parameters to change. I think its best to use the function of the attribute itself, as angle and reference point, which I do now. It would be nice to save time with a "special" rotate-lisp that turns a block 90° and its attributes 180°, but with diagonal reference for every att, so they turn on point. Further I could move each att if wanted Quote Link to comment Share on other sites More sharing options...
Steven P Posted March 30 Share Posted March 30 Have a look at Lee Macs attcol lisp - it changes the colour but I think the change from that to changing rotation is easy enough (vla-put-rotation goes in the code and not vla-put-color as the essential change, the rest is just making it nice) Quote Link to comment Share on other sites More sharing options...
Philipp Posted March 30 Author Share Posted March 30 This can be helpful, thanks! Unfortunately I just understand tiny bits of the code and syntax of lisp at all. Maybe it would not be neccessary to rotate the block, just all attributes. But how can I set that every att gets 180° plus AND change the text from left-bottom to upper-right, middle-left to middle-right,.. and so on? ;-------------------=={ Attribute Colour }==-----------------;; ;; ;; ;; Prompts for a selection of attributed blocks and displays ;; ;; a dialog interface enabling the user to change the colour ;; ;; of specific attribute tags. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Version 1.0 - 24-02-2011 ;; ;; ;; ;; First Release. ;; ;;------------------------------------------------------------;; (defun c:AttCol ( / *error* _StartUndo _EndUndo _unique _dclsel _dclimg doc l s ss ) (vl-load-com) ;; © Lee Mac 2011 (or *attcolour* (setq *attcolour* 1)) ;; First time default colour (defun *error* ( msg ) (if doc (_EndUndo doc)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (defun _StartUndo ( doc ) (_EndUndo doc) (vla-StartUndoMark doc) ) (defun _EndUndo ( doc ) (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-EndUndoMark doc) ) ) (defun _unique ( l ) (if l (cons (car l) (_unique (vl-remove (car l) (cdr l)))))) (defun _dclsel ( l / file tmp dch return ) (cond ( (not (and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w")) (write-line (strcat "attcol : dialog { label = \"Attribute Colour\"; spacer;" " : list_box { label = \"Select Tags\"; key = \"tags\"; fixed_width = false; multiple_select = true ; alignment = centered; }" " : boxed_column { label = \"Colour\";" " : row { spacer;" " : button { key = \"but\"; width = 12; fixed_width = true; label = \"Select Colour\"; }" " : image_button { key = \"img\"; alignment = centered; height = 1.5; width = 4.0;" " fixed_width = true; fixed_height = true; color = 2; }" " spacer;" " }" " spacer;" " }" " spacer; ok_cancel;" "}" ) file ) (not (close file)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "attcol" dch) ) ) ) (t (start_list "tags") (mapcar 'add_list l) (end_list) (setq return (set_tile "tags" "0")) (_dclimg "img" *attcolour*) (action_tile "img" "(_dclimg \"img\" (setq *attcolour* (cond ( (acad_colordlg *attcolour*) ) ( *attcolour* ))))") (action_tile "but" "(_dclimg \"img\" (setq *attcolour* (cond ( (acad_colordlg *attcolour*) ) ( *attcolour* ))))") (action_tile "tags" "(setq return $value)") (setq return (if (= 1 (start_dialog)) (mapcar '(lambda ( x ) (nth x l)) (read (strcat "(" return ")"))) ) ) ) ) (if (< 0 dch) (unload_dialog dch)) (if (setq tmp (findfile tmp)) (vl-file-delete tmp)) return ) (defun _dclimg ( k c ) (start_image k) (fill_image 0 0 (dimx_tile k) (dimy_tile k) c) (end_image) ) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (and (ssget "_:L" '((0 . "INSERT") (66 . 1))) (progn (vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc)) (foreach att (append (vlax-invoke obj 'GetAttributes) (vlax-invoke obj 'GetConstantAttributes)) (setq l (cons (cons (vla-get-TagString att) att) l)) ) ) (vla-delete ss) (setq s (_dclsel (acad_strlsort (_unique (mapcar 'car l))))) ) ) (progn (_StartUndo doc) (foreach pair l (if (vl-position (car pair) s) (vla-put-color (cdr pair) *attcolour*))) (_EndUndo doc) ) (princ "\n*Cancel*") ) (princ) ) (princ) (princ "\n:: AttributeColour.lsp | Version 1.0 | © Lee Mac 2011 www.lee-mac.com ::") (princ "\n:: Type \"AttCol\" to Invoke ::") (princ) ;;------------------------------------------------------------;; ;; End of File ;; ;;------------------------------------------------------------;; Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 1 Share Posted April 1 A quick look and a maybe 1st step every attribute needs Middle centre alignment. So can flip 180 but stays in same place. Then just check attribute angle lee-mac has a Text readable lisp a good start for the formula for a test. So for every attribute get rotation. A screwed up example pick your block, note angle is in radians 180=pi. Can use (+ ang pi) (setq obj (vlax-ename->vla-object (car (entsel "\nSelect a object ")))) (setq atts (vlax-invoke obj 'Getattributes)) (setq step 0.25 ang 0.0) (foreach att atts (vlax-put att 'rotation (setq ang (+ ang step))) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.