BHenry85 Posted May 24, 2023 Posted May 24, 2023 Hello all, I am working on a lisp that will relocate the left, right, and rear elevations on the same y plane as the front elevation and rotate them accordingly to match the front, since we draw our elevations around a square. The routine will start by asking the user for the far left point of the front elevations floor line so I get the Y value to place the three other with a predetermined offset of 150'. Then it asks the user to select the object for each elevation and the far left point of the these elevations floor line. It ends with moving these selection sets and rotating them accordingly. The problem that I am having is in the move command with trying to string the destination coordinates. I know that strcat expects a string and not an integer value, and I have tried a few methods of trying to convert this using itoa, rtos, and number-to-string but I keep getting the errors shown below and it breaks at portion of the Move command where it calls in the value of the "fey" variable. (setq fey (rtos (cadr fept))) <"-127'-0\""> (setq fey (itoa (cadr fept))) <bad argument type: fixnump: -1524.0> (setq fey (number-to-string (cadr fept))) = (number-to-string (cadr fept)) <unrecognized command: number-to-string Any suggestions? (defun c:melevs ( / fex lex rex rrex fept fey left-elev-ss left-elev-bp right-elev-ss right-elev-bp rear-elev-ss rear-elev-bp) ; Set the coords for each elevation (setq lex "-150',") ;left (setq rex "300',") ;right (setq rrex "450',") ;rear (setq zval ",0") ;default z ; Get front elevation (setq fept (getpoint "\nChoose the far left point of the floor line for the Front Elevation: ")) (setq fey (cadr fept)) ; set front elev y coord to variable ; Set left elevation coords (setq left-elev-ss (ssget (prompt "\nSelect all objects for the Left Elevation: "))) (setq left-elev-bp (getpoint "\nChoose the far left point of the floor line for the Left Elevation: ")) ; Set right elevation coords (setq right-elev-ss (ssget (prompt "\nSelect all objects for the Right Elevation: "))) (setq right-elev-bp (getpoint "\nChoose the far left point of the floor line for the Right Elevation: ")) ; Set rear elevation coords (setq rear-elev-ss (ssget (prompt "\nSelect all objects for the Rear Elevation: "))) (setq rear-elev-bp (getpoint "\nChoose the far left point of the floor line for the Rear Elevation: ")) ; Move left elev (command "rotate" left-elev-ss "" left-elev-bp "90") (command "move" left-elev-ss "" left-elev-bp (strcat lex fey zval)) ; Move right elev (command "rotate" right-elev-ss "" right-elev-bp "90") (command "move" right-elev-ss "" right-elev-bp (strcat rex fey zval)) ; Move rear elev (command "rotate" rear-elev-ss "" rear-elev-bp "90") (command "move" rear-elev-ss "" rear-elev-bp (strcat rrex fey zval)) ; Display routine complete (princ "\nElevations have been relocated!") (princ) ) Test File.dwg Quote
JerryFiedler Posted May 25, 2023 Posted May 25, 2023 As far as I know a point is a list NOT a string. Try changing the definitions of rrex, fey, and zval to integers or reals like (setq rrex 450.0). Then the point will be (list rrex fey zval). Quote
BIGAL Posted May 25, 2023 Posted May 25, 2023 (edited) You already have 4 UCS directions set so why not use those when drawing your elevations ? UCS R ucsname Plan. This will rotate the model view to match the house direction. no need to rotate & move elevations. UCS W Plan to go back to real world. Edited May 25, 2023 by BIGAL 1 Quote
BHenry85 Posted May 25, 2023 Author Posted May 25, 2023 12 hours ago, BIGAL said: You already have 4 UCS directions set so why not use those when drawing your elevations ? UCS R ucsname Plan. This will rotate the model view to match the house direction. no need to rotate & move elevations. UCS W Plan to go back to real world. That is exactly what we do while we draw the model and do any updates for it. This routine above is just the start of one for our Artwork department that will be importing it into 3DS Max and they requested to have the models reoriented so the elevations are side by side. As I stated initially, I know that strcat expects a string and not an integer, that was why I was trying to convert it to one in order to get that method to work. It appears to accept "lex", "rex", and "rrex" (Left, Right, and Rear X variable values I define at the beginning, but doesn't know how to handle "fey" (front elevation y) value that the user supplies when selecting the front elevation floor line. Quote
JerryFiedler Posted May 26, 2023 Posted May 26, 2023 BH, you are mixing strings and real numbers. You obtain fey from a getpoint command which returns a three member list of the X, Y and Z. Therefore (cadr fept) is going to be a real number representing the Y coordinate. (Real number meaning a decimal number not a string that looks like a decimal number. I believe you can fix your routine by changing the four elevation assignments at " ; set the coords at each elevation" to (setq lex -150.) and similarly for the other three variables. Then in your move command change (strcat rrex fey zval) to (list rrex fey zval). Quote
Steven P Posted May 26, 2023 Posted May 26, 2023 So debugging, you might try the 'Type' LISP command (type 123) = INT (type 12.3) = REAL (type "ABD") or (type "12.3") = STRING which could be used with an IF to use the appropriate ITOA, RTOS, etc. You could also put in a (princ ... ) command part way through the LISP to show you what is going on in there,. after perhaps (setq fey (cadr fept)) ; set front elev y coord to variable (princ fey)(princ " : ") (princ (type fey)) ; Set left elevation coords Weekend... CAD is off here though so that is the best I'll do tonight Quote
BIGAL Posted May 27, 2023 Posted May 27, 2023 Why code I just selected the view and did select a view and rotate eg 90 & -90 and 180 all done. If you want like a box answer lee-mac has get a bounding box of multiple objects so can use that for say a copy or move and rotate placing views side by side. 1 Quote
BHenry85 Posted May 30, 2023 Author Posted May 30, 2023 On 5/25/2023 at 10:09 PM, JerryFiedler said: I believe you can fix your routine by changing the four elevation assignments at " ; set the coords at each elevation" to (setq lex -150.) and similarly for the other three variables. Then in your move command change (strcat rrex fey zval) to (list rrex fey zval). When I change the elevation coord variables to remove the "" like: (setq fex -150') ;front (setq lex 150') ;left (setq rex 300') ;right (setq rrex 450') ;rear (setq zval 0') ;default z I get an "extra right paren on input" error. Please see the attached "Move Elevations.lsp" to see the updated code. On 5/26/2023 at 3:00 PM, Steven P said: (type 123) = INT (type 12.3) = REAL (type "ABD") or (type "12.3") = STRING which could be used with an IF to use the appropriate ITOA, RTOS, etc. When I inserted (princ fey)(princ " : ") (princ (type fey)) into the code, it displayed "-1532.0 : REAL" in the command line. So, this puts back to my original conclusion and I added (setq feyy (rtos fey)) and it displays "-127'-8\"" in the command line. This has allowed the command to finish, but the desired locations are off, so I will continue to tweak things to see if I can get it where I need it. On 5/26/2023 at 8:02 PM, BIGAL said: Why code I just selected the view and did select a view and rotate eg 90 & -90 and 180 all done. If you want like a box answer lee-mac has get a bounding box of multiple objects so can use that for say a copy or move and rotate placing views side by side. I already have commands that do this for us and we use the num pad (2, 4, 6, and 8 ) to set our views. I have attached a slimmed down version of what we use to define/reset the views within the dwg file and defun the num keys to rotate the view accordingly (See the attached ResetViews.lsp file). The reason for this new routine is to prep a drawing to be imported into 3D Studio Max by our artwork department. They build a 3d model out of our 2d linework and requested something like this that will re-orientate the elevations side by side so it is easier for them downstream as they are starting their work. ResetViews.lsp Move Elevations.lsp Quote
JerryFiedler Posted May 31, 2023 Posted May 31, 2023 Removing the " " from your (setq ...) was not enough. Typing 150' on the command line works but I do not believe you can do that in the (setq...) function. If your drawing units are feet (which I doubt) then (setq lex 150) will work. Most likely your drawing units are inches so use (setq lex (* 12 150)). The AutoCAD help states that the argument can be an integer, real or string plus others. I do not think the autolisp interpreter understands 150'. I am away from my AutoCAD computer for the rest of this week so I cannot test this. Have you ever used the foot symbol in your other routines? Quote
Steven P Posted May 31, 2023 Posted May 31, 2023 As Jerry says, setq should be unitless to be a number ( 150 and not 150" for example). If you want to use a unit then you'll need to make it as a string and remembering special characters so 150" would be (setq fex "150\"") (using inches for the example, I know you were using feet above) 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.