juicyorange Posted November 14, 2019 Posted November 14, 2019 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 Quote
dlanorh Posted November 14, 2019 Posted November 14, 2019 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. Quote
juicyorange Posted November 14, 2019 Author Posted November 14, 2019 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). Quote
dlanorh Posted November 15, 2019 Posted November 15, 2019 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 Quote
dlanorh Posted November 15, 2019 Posted November 15, 2019 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. Quote
juicyorange Posted November 15, 2019 Author Posted November 15, 2019 (edited) 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 November 15, 2019 by juicyorange Quote
juicyorange Posted November 15, 2019 Author Posted November 15, 2019 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 Quote
dlanorh Posted November 15, 2019 Posted November 15, 2019 (edited) 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 November 15, 2019 by dlanorh Quote
rlx Posted November 15, 2019 Posted November 15, 2019 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? and yes , there is still a hippie sitting in MY place on the couch Quote
dlanorh Posted November 15, 2019 Posted November 15, 2019 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? and yes , there is still a hippie sitting in MY place on the couch Yup, got out this afternoon. But still suffering the from the after affects of Dulcolax. Quote
rlx Posted November 15, 2019 Posted November 15, 2019 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 1 Quote
dlanorh Posted November 15, 2019 Posted November 15, 2019 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 Many thanks @rlx Quote
BIGAL Posted November 16, 2019 Posted November 16, 2019 Cheap high, you know the medicine that says no alcohol Quote
juicyorange Posted November 19, 2019 Author Posted November 19, 2019 (edited) 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 November 19, 2019 by juicyorange Quote
Recommended Posts
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.