TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: One Shot on May 29, 2008, 10:10:31 AM

Title: inserting data in wrong place holder
Post 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.
Title: Re: inserting data in wrong place holder
Post by: Keith™ on May 29, 2008, 10:50:50 AM
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?
Title: Re: inserting data in wrong place holder
Post by: One Shot on May 29, 2008, 11:08:27 AM
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
Title: Re: inserting data in wrong place holder
Post by: ronjonp on May 29, 2008, 11:25:01 AM
Maybe this could help you out:

Code: [Select]
(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")
Title: Re: inserting data in wrong place holder
Post by: One Shot on May 29, 2008, 03:57:46 PM
Where would I add this section or modify the existing?

Thank you,

Brad
Title: Re: inserting data in wrong place holder
Post by: ronjonp on May 29, 2008, 04:10:15 PM
Maybe by modifying this part:

Code: [Select]
  (command "_Insert"   "Room-Tag"  inspt       inscale2    ""
   dv-angle-fix    ""    ""
   ""    ""    "XXX"       ""
  )
  (setq blk (entlast))
  (rjp-putattvalue blk "room" exst-roomnum)
  (rjp-putattvalue blk "area" roomarea)
Title: Re: inserting data in wrong place holder
Post by: One Shot on May 29, 2008, 04:38:19 PM
Maybe by modifying this part:

Code: [Select]
  (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!
Title: Re: inserting data in wrong place holder
Post by: ronjonp on May 29, 2008, 04:40:50 PM
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.
Title: Re: inserting data in wrong place holder
Post by: CAB on May 29, 2008, 11:40:14 PM
Brad,
Try this to see if the code is working for you.
Code: [Select]
(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)
)
Title: Re: inserting data in wrong place holder
Post by: One Shot on May 30, 2008, 10:20:46 AM
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

Code: [Select]
; (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.
Code: [Select]
(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)
)