- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi.
Im having trouble getting this code to work.
Can anyone look at it for me?
(defun get_xdata_object ()
(setq blks nil)
(and
(setq ss (ssget '((0 . "INSERT"))))
(setq i (sslength ss))
(while (> i 0)
(setq blk (cdr (assoc 2 (entget (ssname ss (setq i (1- i)))))))
(if (not (vl-position blk blks))(setq blks (cons blk blks)))
)
);end and
(foreach blk blks
(vl-load-com)
(setq def (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blk))
(setq ent (vlax-ename->vla-object (ssname ss 0)))
); end foreach
(setq xdata-line (car (entsel "\nSelect line containing XData: ")))
);End Defun
(defun addattrtest1 (def)
(foreach blk blks
(vl-load-com)
(setq tag1 (cdr (assoc "searchtag1" (get_xd_list xdata-line))))
(vla-addattribute def
2.5
acAttributeModeInvisible
"searchtag1"
(vlax-3D-point 0 0)
"searchtag1"
tag1 ; use the value of searchtag1 as the attribute value
)
(princ)
);end foreach
);End Defun
(defun addattrtest2 (def)
(foreach blk blks
(vl-load-com)
(setq tag2 (cdr (assoc "searchtag2" (get_xd_list xdata-line))))
(vla-addattribute def
2.5
acAttributeModeInvisible
"searchtag2"
(vlax-3D-point 0 0)
"searchtag2"
tag2 ; use the value of searchtag2 as the attribute value
)
(princ)
);end foreach
);End Defun
(defun addattrtest3 (def)
(foreach blk blks
(vl-load-com)
(setq tag3 (cdr (assoc "searchtag3" (get_xd_list xdata-line))))
(vla-addattribute def
2.5
acAttributeModeInvisible
"searchtag3"
(vlax-3D-point 0 0)
"searchtag3"
tag3 ; use the value of searchtag3 as the attribute value
)
(princ)
);end foreach
);End Defun
(defun refreshblock (blk)
(vl-load-com)
(command "_.attsync" "_N" blk)
);End Defun
(defun c:addattrtest ( )
;(setq *error* 'xx:Error)
(initget 1 "Option1 Option2 Option3 All3")
(setq option (getkword "\nHvilken Attributt pakke vil du legge til 3D solid?:[Option1/Option2/Option3/All3]"))
(cond ((= option "Option1") (get_xdata_object)(addattrtest1)(refreshblock))
((= option "Option2") (get_xdata_object)(addattrtest2)(refreshblock))
((= option "Option3") (get_xdata_object)(addattrtest3)(refreshblock))
((= option "All3") (get_xdata_object)(addattrtest1)(addattrtest2)(addattrtest3)(refreshblock))
(t (princ "Invalid option")))
; (*error* "end")
);End Defun
What i want to do is post attributes from xdata.
it askes to choose a block first. then the line with xdata in.
i cant post an example drawing unfortunately because its for work.
But as im having trouble with adding alot off attributes at a time. I modified my original code and splitt it up to hopefully get it more user friendly.
im also having trouble with trying to get it to just move on if it encounters a NIL.
originally every option adds 8 attributes at a time. But i cut it down to not make the code so long here.
For some reason i cant get it to work for more then 8 at a time..
the command "get_xd_list" is our call command for xdata for the costum program my work place use. So i dont need an reference to it anyplace in my code.
the error im getting is:
Command: ADDATTRTEST
Hvilken Attributt pakke vil du legge til 3D solid?:[Option1/Option2/Option3/Alle3]A
Select objects: 1 found
Select objects:
Select line containing XData: ; error: too few arguments
Command:
any advice is much appretiated.
Solved! Go to Solution.