TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: One Shot on May 29, 2008, 10:10:31 AM
-
I use this lisp here at work to export/import room data to and from dwgs. The way this lisp works is that first you pick the pl of an area and then you select the room number. When the function is completed, the room number is replaced with this attribute. The room number and the area is inserted as a field. It works great, but it is inserting the area in the wrong place holder. The area field is being inserted in the last name place holder.
I have looked over this lisp several times to try to figure where to change it. I cannot locate it in the lisp. Can someone please help me out.
-
I see by the lisp, that you are hard coding the location of the room area. Perhaps the order of the fields in the block are not the same as the order you are inserting the value. Does this happen always?
-
I see by the lisp, that you are hard coding the location of the room area. Perhaps the order of the fields in the block are not the same as the order you are inserting the value. Does this happen always?
It happens all the time.
The order of the attribute is as followed:
Room
Firstname
Lastname
Area
Accom
Org
-
Maybe this could help you out:
(defun rjp-putattvalue (block tag value / att)
(if (= (type block) 'ENAME)
(setq block (vlax-ename->vla-object block))
)
(if (= (vla-get-hasattributes block) :vlax-true)
(foreach att (vlax-invoke block 'getattributes)
(if (eq (strcase tag)
(strcase (vla-get-tagstring att))
)
(vla-put-textstring att value)
)
)
)
(princ)
)
;;(putattvalue (car (entsel)) "tagname" "value")
-
Where would I add this section or modify the existing?
Thank you,
Brad
-
Maybe by modifying this part:
(command "_Insert" "Room-Tag" inspt inscale2 ""
dv-angle-fix "" ""
"" "" "XXX" ""
)
(setq blk (entlast))
(rjp-putattvalue blk "room" exst-roomnum)
(rjp-putattvalue blk "area" roomarea)
-
Maybe by modifying this part:
(command "_Insert" "Room-Tag" inspt inscale2 ""
dv-angle-fix "" ""
"" "" "XXX" ""
)
(setq blk (entlast))
(rjp-putattvalue blk "room" exst-roomnum)
(rjp-putattvalue blk "area" roomarea)
Did not work!
-
Did you load the subroutine?
*After really looking at your routine, I'm not real sure what you are doing :?
I assumed you were selecting a closed polyline, selecting something else that has a room number, and then inserting a block and putting that data into it.
-
Brad,
Try this to see if the code is working for you.
(defun c:test (/ blk ss)
(defun rjp-putattvalue (block tag value / att)
(if (= (type block) 'ENAME)
(setq block (vlax-ename->vla-object block))
)
(if (= (vla-get-hasattributes block) :vlax-true)
(foreach att (vlax-invoke block 'getattributes)
(if (eq (strcase tag)
(strcase (vla-get-tagstring att))
)
(vla-put-textstring att value)
)
)
)
(princ)
)
(prompt "\nSelect a Room Block to test.")
(if (setq ss (ssget "_+.:E:S" '((0 . "INSERT")(2 . "Room-Tag"))))
(progn
(setq blk (ssname ss 0))
(rjp-putattvalue blk "room" "RM1")
(rjp-putattvalue blk "area" "51")
)
)
(princ)
)
-
I pasted this into the code and it ran, but the attribute did not insert.
In the main code I found where it is not placing it in the correct place holder. I was playing around with it last night but got it to work but the area did not insert in the attribute.
Thank you,
Brad
; (command "_Insert" "C:\Documents and Settings\bcrouse\Desktop\Work Folder\CUI - Lisp" inspt inscale2 "" dv-angle-fix exst-roomnum "" "XXX" "" "XXX" " "")
(command "_Insert" "Room-Tag" inspt inscale2 "" dv-angle-fix exst-roomnum "" roomarea "" "XXX" "")
Brad,
Try this to see if the code is working for you.
(defun c:test (/ blk ss)
(defun rjp-putattvalue (block tag value / att)
(if (= (type block) 'ENAME)
(setq block (vlax-ename->vla-object block))
)
(if (= (vla-get-hasattributes block) :vlax-true)
(foreach att (vlax-invoke block 'getattributes)
(if (eq (strcase tag)
(strcase (vla-get-tagstring att))
)
(vla-put-textstring att value)
)
)
)
(princ)
)
(prompt "\nSelect a Room Block to test.")
(if (setq ss (ssget "_+.:E:S" '((0 . "INSERT")(2 . "Room-Tag"))))
(progn
(setq blk (ssname ss 0))
(rjp-putattvalue blk "room" "RM1")
(rjp-putattvalue blk "area" "51")
)
)
(princ)
)