thereisnotime Posted November 1, 2016 Share Posted November 1, 2016 Inside my main LISP, the user is prompted to select 2 points on screen and I want to rotate the text based on those 2 clicks. I've tried to keep it simple and run the TORIENT command after the text is inserted but it keeps giving me an error that TORIENT is an unknown command....any thoughts? (defun getTextData (lineObj textVal) (setq pt1 (getpoint "\nSelect Insertion Point: ")) (setq ro1 (getpoint "\nRotation: Specify first point: ")) (setq ro2 (getpoint "Specify second point:")) (entmake (list '(0 . "TEXT") '(8 . "DR_PJ_L") ; Change this for different Layer (cons 10 pt1) (cons 40 0.3) ; Change this for different height (cons 1 textVal) '(50 . 0.0) ; Text rotation '(7 . "ANNO TEXT_") ; change this for different Text Style '(71 . 0) '(72 . 0) '(73 . 0) ) ;_ end list ) ;_ end entmake (setq e (entlast)) (command "_chprop" e "" "A" "Yes" "") ; Change text to annotative (command "_torient" e ro1 ro2) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 1, 2016 Share Posted November 1, 2016 I would suggest the following modifications to your code: (defun gettextdata ( lineobj str / ang ins txt ) (if (and (setq ins (getpoint "\nSpecify insertion point: ")) (setq ang (getangle "\nSpecify rotation: " ins)) (setq txt (entmakex (list '(0 . "TEXT") '(8 . "DR_RJ_L") (cons 10 (trans ins 1 0)) '(40 . 0.3) (cons 1 str) (cons 50 ang) (cons 7 (if (tblsearch "STYLE" "ANNO TEXT_") "ANNO TEXT_" (getvar 'textstyle))) ) ) ) ) (command "_.chprop" txt "" "_A" "_Y" "") ) txt ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 1, 2016 Share Posted November 1, 2016 Also you might want to utilise this: ;; Readable - Lee Mac ;; Returns an angle corrected for text readability. (defun LM:readable ( a ) ( (lambda ( a ) (if (< a 0.0) (LM:readable a) (if (and (< (* pi 0.5) a) (<= a (* pi 1.5))) (LM:readable (+ a pi)) a ) ) ) (rem (+ a pi pi) (+ pi pi)) ) ) Quote Link to comment Share on other sites More sharing options...
thereisnotime Posted November 1, 2016 Author Share Posted November 1, 2016 I would suggest the following modifications to your code: Thanks, Lee. I thought about doing that, where the insertion point would be the start of the text angle. I think that would be the best idea...they can specify where the text will be, rotate it to the line they're trying to label and get it pretty close. If they're really picky, they can TORIENT it after if they want to. My main question is how the entmakex works...am I understanding it correctly that the function assigns all the information necessary to create an object to a variable, but won't initiate it until the variable is called? If that's so, I had no idea you could initiate a variable out of the blue like that! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 1, 2016 Share Posted November 1, 2016 My main question is how the entmakex works...am I understanding it correctly that the function assigns all the information necessary to create an object to a variable, but won't initiate it until the variable is called? If that's so, I had no idea you could initiate a variable out of the blue like that! Not quite - the DXF data supplied to entmakex is immediately appended to the drawing database when entmakex is evaluated (provided that the evaluation is successful, else entmakex will return nil); if successful, entmakex will return a pointer (entity name) to the new database entry, which avoids the need to use entlast to retrieve the same information. I've enclosed this expression, along with the getXXX expressions within the test expression for the if statement to ensure that valid data is obtained and a valid entity created prior to the annotative property modification. Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 2, 2016 Share Posted November 2, 2016 A small suggestion: '(8 . "DR_RJ_L") (cons 8 (if (tblsearch "LAYER" "DR_RJ_L") "DR_RJ_L" (getvar 'clayer))) Quote Link to comment Share on other sites More sharing options...
thereisnotime Posted November 2, 2016 Author Share Posted November 2, 2016 A small suggestion: '(8 . "DR_RJ_L") (cons 8 (if (tblsearch "LAYER" "DR_RJ_L") "DR_RJ_L" (getvar 'clayer))) Just curious...if I know the DR_PJ_L layer is in the drawing, why would this extra check be needed? Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 2, 2016 Share Posted November 2, 2016 Just curious...if I know the DR_PJ_L layer is in the drawing, why would this extra check be needed? Why would you risk the program to crash? What if in your next program you did a typo on the layer's name? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted November 2, 2016 Share Posted November 2, 2016 Entmake(x) will automatically create missing layers there is no need for the check that Grrr has suggested. Quote Link to comment Share on other sites More sharing options...
Grrr Posted November 2, 2016 Share Posted November 2, 2016 Entmake(x) will automatically create missing layers there is no need for the check that Grrr has suggested. Roy is correct, as always... dammit: _$ (entmakex (list (cons 0 "LINE") (cons 8 "NewUnexistingLayer") (cons 10 (getpoint)) (cons 11 (getpoint)))) <Entity name: 7ff7ea9875f0> _$ Sorry. 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.