Attila The Gel Posted September 21, 2012 Share Posted September 21, 2012 Hi, I'm stuck again trying to recreate a lisp & dcl that someone else made where I work? for learning purpose! I don't have the source code so its a perfect example to start with from scratch. I would like to return the coordinates into a form to a text, key:"txt(xyz)". ;; dialog is hidden when I click a button to get point (setq [color=seagreen]CRDNTS [/color](getpoint "\nInsertion point: ")) [color=seagreen];=example (102.08 25.85 0.0)[/color]. ;; Dialog is reloaded and then... (set_tile "txt(xyz)" [color=seagreen]CRDNTS [/color]) [color=red]not working because its not a string[/color]? I tried some conversion but couldn't get it to work? Do I need to extract the x,y and z and then list it back together? or is there a simple solution to get this done. thx. Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 21, 2012 Share Posted September 21, 2012 The point returned by GETPOINT is in fact a list of 2 or 3 items. You should decompose it and build the string. (strcat (rtos (car CRDNTS) 2 3) ", " (rtos (cadr CRDNTS) 2 3)) However it is a little unusual to display the point into an edit box like above - most common is to have fields for each coordinate. The first approach can pose input difficulties to user. Quote Link to comment Share on other sites More sharing options...
Attila The Gel Posted September 21, 2012 Author Share Posted September 21, 2012 You're right about the edit box and displaying the point in it, but I'm trying to get it into a text field and its just to inform the user that the insertion point is selected and it's not (0.0 0.0 0.0). Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 21, 2012 Share Posted September 21, 2012 Then set that label like this: (set_tile [color=magenta]"labelCoordsInfo"[/color] (strcat "Coordinaten = (" (rtos (car CRDNTS) 2 3) ", " (rtos (cadr CRDNTS) 2 3) ", " (rtos (caddr CRDNTS) 2 3) ")")) For sure, will need to replace the tile key accordingly. Quote Link to comment Share on other sites More sharing options...
Attila The Gel Posted September 21, 2012 Author Share Posted September 21, 2012 Then set that label like this: (set_tile [color=magenta]"labelCoordsInfo"[/color] (strcat "Coordinaten = (" (rtos (car CRDNTS) 2 3) ", " (rtos (cadr CRDNTS) 2 3) ", " (rtos (caddr CRDNTS) 2 3) ")")) For sure, will need to replace the tile key accordingly. Exactly what I was looking for and even better! Thx again MSasu Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 21, 2012 Share Posted September 21, 2012 You're entirely welcome! Quote Link to comment Share on other sites More sharing options...
Attila The Gel Posted September 21, 2012 Author Share Posted September 21, 2012 Countered another problem regarding this when loading a fresh routine. Value of CRDNTS = nil and the dialog closes with the error message bad bla bla bla nil. so I've put it in an if: (if (= CRDNTS nil) (set_tile "labelCoordsInfo" "Coordinaten = ( 0,0 0,0 0,0 )") (set_tile "labelCoordsInfo" (strcat "Coordinaten = ( " (rtos (car CRDNTS) 2 1) " , " (rtos (cadr CRDNTS) 2 1) " , " (rtos (caddr CRDNTS) 2 1) " ) ")) ) just in case someone is in need of this or similar things. Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 21, 2012 Share Posted September 21, 2012 You may check also the NOT function. (if (not CRDNTS) ... Or check the point for existency and invert the messages: (if CRDNTS ... Either way, make sure that the said variable is localized to don't have assigned it from previoud run. May also want to reformat the default message for consistency: (set_tile "labelCoordsInfo" "Coordinaten = ( 0.0 , 0.0 , 0.0 )") Quote Link to comment Share on other sites More sharing options...
Attila The Gel Posted September 21, 2012 Author Share Posted September 21, 2012 Hey, Thanks for taking the time to reflect different possibilities and correcting typo's. I'll look into the NOT function better. Don't get the existence though. Could it be that (if CRDNTS actually means that CRDNTS ISNOT NIL.Equals to existence of it. Just the reverse of Not CRDNTS and that is why the message needs to be inverted? Its just so damn short that I need to know how it works or thinks so to speak, to be able to understand it properly. Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 21, 2012 Share Posted September 21, 2012 If will test that the point is available, then the code become: (if CRDNTS (set_tile "labelCoordsInfo" (strcat "Coordinaten = ( " (rtos (car CRDNTS) 2 1) " , " (rtos (cadr CRDNTS) 2 1) " , " (rtos (caddr CRDNTS) 2 1) " ) ")) (set_tile "labelCoordsInfo" "Coordinaten = ( 0.0 , 0.0 , 0.0 )") ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 21, 2012 Share Posted September 21, 2012 Don't get the existence though. Could it be that (if CRDNTS actually means that CRDNTS ISNOT NIL.Equals to existence of it. In AutoLISP, any value that is not equal to nil is considered a 'true' value and will validate the test expression of an if, cond, while statement etc. Hence for the test expression: ([color=blue]if[/color] [color=darkred]CRDNTS[/color] ... The symbol CRDNTS is evaluated and if such symbol has been assigned a value other than nil, the test expression is validated and the 'then' expression of the if statement will be evaluated. Quote Link to comment Share on other sites More sharing options...
Attila The Gel Posted September 21, 2012 Author Share Posted September 21, 2012 Clarified! and very useful! 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.