Author Topic: inserting data in wrong place holder  (Read 2792 times)

0 Members and 1 Guest are viewing this topic.

One Shot

  • Guest
inserting data in wrong place holder
« 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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16897
  • Superior Stupidity at its best
Re: inserting data in wrong place holder
« Reply #1 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?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

One Shot

  • Guest
Re: inserting data in wrong place holder
« Reply #2 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

ronjonp

  • Needs a day job
  • Posts: 7462
Re: inserting data in wrong place holder
« Reply #3 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")
« Last Edit: May 29, 2008, 11:31:41 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

One Shot

  • Guest
Re: inserting data in wrong place holder
« Reply #4 on: May 29, 2008, 03:57:46 PM »
Where would I add this section or modify the existing?

Thank you,

Brad

ronjonp

  • Needs a day job
  • Posts: 7462
Re: inserting data in wrong place holder
« Reply #5 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)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

One Shot

  • Guest
Re: inserting data in wrong place holder
« Reply #6 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!

ronjonp

  • Needs a day job
  • Posts: 7462
Re: inserting data in wrong place holder
« Reply #7 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.
« Last Edit: May 29, 2008, 04:45:59 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10400
Re: inserting data in wrong place holder
« Reply #8 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)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

One Shot

  • Guest
Re: inserting data in wrong place holder
« Reply #9 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)
)