mpozauko Posted January 4, 2012 Share Posted January 4, 2012 Hey guys. I wonder if anyone can help me with my situation. I am using AC Map 2008 and i have 3D plines each one defined with some OD Attributes. What i would like to do is to put some text from OD into block attributes and then insert that block on start of the pline. I already use LeeMacs lisp to insert block but then i have to first use ATTSYNC command and manualy fill in block attributes with the data from OD. Lisp i use: ;;-------------------=={ Block At Ends }==--------------------;; ;; ;; ;; Inserts a Block at each endpoint of a polyline ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; (defun c:BlockAtEnds ( / *error* _StartUndo _EndUndo _Insert _AngleAtParam doc block ss ) (vl-load-com) ;; © Lee Mac 2010 (setq block "profilD_fi110_fi50_fi40.dwg") ;; << Block Name (defun *error* ( msg ) (and 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 _Insert ( block point rotation ) (entmakex (list (cons 0 "INSERT") (cons 2 block) (cons 10 point) (cons 50 rotation) ) ) ) (defun _AngleatParam ( entity param ) (angle '(0. 0. 0.) (vlax-curve-getFirstDeriv entity param)) ) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (cond ( (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar 'CLAYER)))))) (princ "\n** Current Layer Locked **") ) ( (not (or (and (tblsearch "BLOCK" (vl-filename-base block)) (setq block (vl-filename-base block)) ) (and (setq block (findfile (strcat block (if (eq "" (vl-filename-extension block)) ".dwg" "") ) ) ) ( (lambda ( / ocm ) (setq ocm (getvar 'CMDECHO)) (setvar 'CMDECHO 0) (command "_.-insert" block) (command) (setvar 'CMDECHO ocm) (tblsearch "BLOCK" (setq block (vl-filename-base block))) ) ) ) ) ) (princ "\n** Block not Found **") ) ( (not (setq ss (ssget '((0 . "*POLYLINE"))))) (princ "\n*Cancel*") ) (t (_StartUndo doc) ( (lambda ( i / e ) (while (setq e (ssname ss (setq i (1+ i)))) (foreach param (list (vlax-curve-getStartParam e) ) (_Insert block (vlax-curve-getPointatParam e param) (_AngleAtParam e param)) ) ) ) -1 ) (_EndUndo doc) ) ) (princ) ) Block "profilD_fi110_fi50_fi40.dwg" has 3 tags FI110, FI50, FI40 which i would like to fill with text from OD with FI110, FI50, FI40 OD Field names. These fields are filled with letter "o" that represents number of pipes with defined diameter. So basically i would fill in number of pipes for all 3dPlines (sections of pipeline) in OD Fields and when i would use lisp routine it would place blocks with correct attributes from OD on the start of the section (3dPline). I attached DWG drawing "test.dwg" with containing block and some sections of pipeline filled with number of pipes in OD Fields. I also attached one picture of OD Table structure. Hope i was clear enough. test.dwg Quote Link to comment Share on other sites More sharing options...
mpozauko Posted January 6, 2012 Author Share Posted January 6, 2012 ok, i managed to do this by creating annotations and is working well. thanks anyway. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 6, 2012 Share Posted January 6, 2012 Glad you were able to solve your problem, sorry that I didn't have the time to investigate this. Quote Link to comment Share on other sites More sharing options...
Dien nguyen Posted March 20, 2023 Share Posted March 20, 2023 I have the same problem but copy block attribute value to object data, please help! att.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 20, 2023 Share Posted March 20, 2023 (edited) If you look at this line, (setq Stnum (ade_odgetfield ent odname "STREET_NUMBER" 0)) There is a put version of this trying to find an example pretty sure its there. https://documentation.help/AutoCAD-Map-3D-2009-AutoLISP/object_data_functions.htm Edited March 20, 2023 by BIGAL Quote Link to comment Share on other sites More sharing options...
Tsuky Posted March 20, 2023 Share Posted March 20, 2023 9 hours ago, Dien nguyen said: I have the same problem but copy block attribute value to object data, please help! att.dwg 950.25 kB · 1 download With your exemple, this can do the job (defun c:att2OD ( / ss n ent obj) (vl-load-com) (setq ss (ssget '( (0 . "INSERT") (66 . 1) (2 . "K-D-PARCEL") ) ) ) (cond (ss (repeat (setq n (sslength ss)) (setq obj (vlax-ename->vla-object (setq ent (ssname ss (setq n (1- n)))))) (mapcar '(lambda (att) (if (eq (vlax-get att 'TagString) "level1") (ade_odsetfield ent "def" "level" 0 (atof (vlax-get att 'TextString))) ) ) (vlax-invoke obj 'GetAttributes) ) ) ) ) (prin1) ) 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.