Jump to content

How to put data into a specific attribute in a block while inserting a block into a drawing


juicyorange
 Share

Recommended Posts

Hey all,

 

I have a block (attached) that I'd like to insert into a drawing and after it's placed I'd like to populate the "PointNo" and "Descr" attributes with some user inputted data.

 

I honestly have no idea where to start and appreciate any and all starting tips or help.

 

Thanks,

 

JT

COORD ID.dwg

Link to comment
Share on other sites

Are you a complete newbie re lisp? I can give you a function to update any attribute in an attributed block based on the tag name, and code to insert the block, but it is written in visual lisp.

Link to comment
Share on other sites

7 minutes ago, dlanorh said:

Are you a complete newbie re lisp? I can give you a function to update any attribute in an attributed block based on the tag name, and code to insert the block, but it is written in visual lisp.

 

Not a complete newbie, I have written some lines of code.

 

I'm looking to add this function to an existing routine I wrote that inserts points based on a csv file. I want to replace those autocad objects with the block I attached and to pull data from the csv file (I already have all this figured out).

 

Ultimately, what I need is to use the insert function, somehow find the attribute I need inside of the current block (this piece I need the most help with) and write to the attribute the variable I have assigned to the value (PointNO/Descr).

Link to comment
Share on other sites

I have been playing with your block. I assume that attributes with TAGS Easting Northing Elev and Azimuth are set up with fields. If so it might be a good idea to set these attributes to PRESET, then you won't be prompted to fill a value when inserted by hand.

Link to comment
Share on other sites

26 minutes ago, dlanorh said:

I have been playing with your block. I assume that attributes with TAGS Easting Northing Elev and Azimuth are set up with fields. If so it might be a good idea to set these attributes to PRESET, then you won't be prompted to fill a value when inserted by hand.

Just got into work, going to look at your code now, but thank you for this!

 

I've been trying to figure out how to prevent the box from popping up!

Edited by juicyorange
Link to comment
Share on other sites

13 hours ago, dlanorh said:

Attached is starter.lsp with most of what you need to insert a block and put values into attributes. If you need more help/pointers just shout.

starter.lsp 2.48 kB · 5 downloads

 

OK so I've started my attempt to incorporate your code.

 

For some reason, I am getting the following error:

 

Error: lisp value has no coercion to VARIANT with this type:  (110 110 110); reset after error

I am not familiar with this one and I can't find much online about it.

 

I know there is a lot of extraneous code and some obvious errors that need to be trapped, I intend on getting it cleaned up after I get this part of the code working. I've attached it so you can see exactly what I'm working with.

 

Thanks,

 

JT

testimport.csv ImportCSV.lsp

Link to comment
Share on other sites

3 hours ago, juicyorange said:

 

OK so I've started my attempt to incorporate your code.

 

For some reason, I am getting the following error:

 


Error: lisp value has no coercion to VARIANT with this type:  (110 110 110); reset after error

I am not familiar with this one and I can't find much online about it.

 

I know there is a lot of extraneous code and some obvious errors that need to be trapped, I intend on getting it cleaned up after I get this part of the code working. I've attached it so you can see exactly what I'm working with.

 

Thanks,

 

JT

testimport.csv 997 B · 0 downloads ImportCSV.lsp 5.46 kB · 0 downloads

 

(110 110 110) is not a list of real numbers

 

(setq ...........................
	   Coord (list XVal YVal ZVal); THIS IS PLUGGING THE STRING VALUES INTO THE COORD LIST

Try 

(setq ..........................................
	  Coords (mapcar 'atof (list XVal YVal ZVal))

If you need further pointers look at this thread as it is similar to what you are doing without blocks HERE

Edited by dlanorh
Link to comment
Share on other sites

maybe this helps too :


(if (setq bn (findfile "G:/GN2 Projects/COORD ID.dwg"))
    (progn
      (setq n_obj (vla-insertblock ms (vlax-3d-point Coord) bn 0.15 0.15 0.15 0)
                 atts (vlax-invoke n_obj 'getattributes))
       (rh:put_att_val atts "POINTNO" PtNo)
       (rh:put_att_val atts "DESCR" Descr)
     )
)

 

and sicco , 🤒 oh I mean , dlanorh , have they released you back into the land of the no-sicco's yet? :celebrate:

 

and yes , there is still a hippie sitting in MY place on the couch  🤬

Link to comment
Share on other sites

55 minutes ago, rlx said:

maybe this helps too :

 


(if (setq bn (findfile "G:/GN2 Projects/COORD ID.dwg"))
    (progn
      (setq n_obj (vla-insertblock ms (vlax-3d-point Coord) bn 0.15 0.15 0.15 0)
                 atts (vlax-invoke n_obj 'getattributes))
       (rh:put_att_val atts "POINTNO" PtNo)
       (rh:put_att_val atts "DESCR" Descr)
     )
)

 

and sicco , 🤒 oh I mean , dlanorh , have they released you back into the land of the no-sicco's yet? :celebrate:

 

and yes , there is still a hippie sitting in MY place on the couch  🤬

 

Yup, got out this afternoon. :itsover::geek:  But still suffering the from the after affects of Dulcolax.🚾:stop:

 

 

Link to comment
Share on other sites

Better to be recovering in your own man-cave than in a place where everybody wants your blood and stick needles in you all the time (and make you pay for it as well! the nerve of some people!) Some biological processes may have slowed you down or stopped this past week but nevertheless your creativity & (digital) productivity  has been great 🥇

 

hope your suffering will be over soon :mrgreen:

 

:beer:

  • Like 1
Link to comment
Share on other sites

14 minutes ago, rlx said:

Better to be recovering in your own man-cave than in a place where everybody wants your blood and stick needles in you all the time (and make you pay for it as well! the nerve of some people!) Some biological processes may have slowed you down or stopped this past week but nevertheless your creativity & (digital) productivity  has been great 🥇

 

hope your suffering will be over soon :mrgreen:

 

:beer:

 

Many thanks @rlx :beer:

Link to comment
Share on other sites

On 11/15/2019 at 11:44 AM, dlanorh said:

 

(110 110 110) is not a list of real numbers

 


(setq ...........................
	   Coord (list XVal YVal ZVal); THIS IS PLUGGING THE STRING VALUES INTO THE COORD LIST

Try 

(setq ..........................................
	  Coords (mapcar 'atof (list XVal YVal ZVal))

If you need further pointers look at this thread as it is similar to what you are doing without blocks HERE

 

I ended up using the "vlax-3d-point" to convert the list into the point and it works swimmingly now.

 

thanks,

 

JT

Edited by juicyorange
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...