whosa Posted April 10, 2017 Share Posted April 10, 2017 Hi, I need to add a lot of spot height in a road pavement an I would like to use a lisp. In need to add 2 spot value under the kerb line. The first one (11.11 ex.) in under the kerb the second one (22.22 ex.) is below the kerb. I built a block with 2 prompt values: STREET.dwg Height_1=11.11 Height_2: 22.22 This lisp should work: 1: PICK THE INSERTION POINT. 2: PICK THE FIST VALUE (Height_1) 3: PICK THE SECOND VALUE (Height_2) Usually i used the follow lisp but it is able to add just one value at time. (defun c:CRC (/ sp p) ;; Tharwat 15.Feb.2016 ;; (setq sp (vlax-get (vla-get-activelayout (vla-get-ActiveDocument (vlax-get-acad-object))) 'Block) ) (if (tblsearch "BLOCK" "STREET" ) (while (setq p (getpoint "\nSpecify point :")) (vla-put-textstring (car (vlax-invoke (vla-insertblock sp (vlax-3d-point p) "STREET" 1.0 1.0 1.0 0.0) 'getattributes)) (rtos (/ (caddr p) 1000.) 2 2) ) ) ) (princ) )(vl-load-com) Thanks in advance Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted April 10, 2017 Share Posted April 10, 2017 I would use: (setvar "ATTDIA" 0 ) (setvar "ATTREQ" 1 ) (command "-insert" "STREET" p "1" "1" "0") Because of the ATTREQ variable when inserting the block itll ask for the attributes. Quote Link to comment Share on other sites More sharing options...
whosa Posted April 10, 2017 Author Share Posted April 10, 2017 Thanks, unfortunately I don't know the Lisp code. Can you suggest me how I need to modify the lisp? Thanks Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 10, 2017 Share Posted April 10, 2017 Hi, Are you after picking two points then write them into the Attributed block 'STREET' in order ? Quote Link to comment Share on other sites More sharing options...
whosa Posted April 10, 2017 Author Share Posted April 10, 2017 yes, i would like to do this. Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted April 10, 2017 Share Posted April 10, 2017 (defun c:CRC (/ sp p) (if (tblsearch "BLOCK" "STREET" ) (progn (setq p (getpoint "\nSpecify point :")) (setvar "ATTDIA" 0 ) (setvar "ATTREQ" 1 ) (command "-insert" "STREET" p "1" "1" "0") ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
whosa Posted April 10, 2017 Author Share Posted April 10, 2017 Hi @Aftertouch, this work well but i need to add the value manually. I would like to pick 2 point, get the z value, and use it to fill the attribute values Thanks Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 10, 2017 Share Posted April 10, 2017 yes, i would like to do this. (defun c:crc (/ sp p p1 p2 ats) ;; Tharwat 10.Mar.2017 ;; (setq sp (vlax-get (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)) ) 'block ) ) (if (tblsearch "BLOCK" "STREET") (while (and (setq p (getpoint "\nSpecify insertion point :")) (setq p1 (getpoint "\nSpecify 1st point :")) (setq p2 (getpoint "\nSpecify 2nd point :")) ) (setq ats (vlax-invoke (vla-insertblock sp (vlax-3d-point p) "STREET" 1.0 1.0 1.0 0.0 ) 'getattributes ) ) (mapcar '(lambda (at) (vla-put-textstring at (rtos (/ (caddr (if (= (vla-get-tagstring at) "Height_1") p1 p2 ) ) 1000. ) 2 2 ) ) ) ats ) ) ) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
Aftertouch Posted April 10, 2017 Share Posted April 10, 2017 Sorry, i misunderstood the question. :-) Quote Link to comment Share on other sites More sharing options...
whosa Posted April 10, 2017 Author Share Posted April 10, 2017 Tharwat, thanks for that. i tried the lisp but i get the same height values in two different point with different z value. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 10, 2017 Share Posted April 10, 2017 Tharwat, thanks for that. i tried the lisp but i get the same height values in two different point with different z value. So is that what you wanted or you still in need of any changes? Quote Link to comment Share on other sites More sharing options...
whosa Posted April 10, 2017 Author Share Posted April 10, 2017 (edited) I would like to add the z value of the first point in Height_1 and the z value of the 2nd point on Height_2. Right now your new version of the lisp copy the first z value on both the place (Height_1 and Height_2). Thanks Edited April 10, 2017 by whosa Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 10, 2017 Share Posted April 10, 2017 (if (= (vla-get-tagstring at) "Height_1") p1 p2 ) I would like to add the z value of the first point in Height_1 and the z value of the 2nd point on Height_2 That's what the program does and you can have a look at the above part of codes which means if the tag name is equal to "Height_1" then get the Z coordinate of point one ( p1 ) otherwise get Z of ( p2 ). Quote Link to comment Share on other sites More sharing options...
whosa Posted April 10, 2017 Author Share Posted April 10, 2017 Maybe don't work well on my machine. Attached you can find the test file. test2.dwg STREET.dwg Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 10, 2017 Share Posted April 10, 2017 The tag name is 11.11 and not Height_1 or Height_2 So just change the string in my last posted codes "Height_1" to "11.11" Quote Link to comment Share on other sites More sharing options...
whosa Posted April 10, 2017 Author Share Posted April 10, 2017 perfect. Thanks Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 10, 2017 Share Posted April 10, 2017 perfect. Thanks You're most welcome. Quote Link to comment Share on other sites More sharing options...
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.