Need help with finding PDFSHXTEXT variable

Need help with finding PDFSHXTEXT variable

Anonymous
Not applicable
1,242 Views
4 Replies
Message 1 of 5

Need help with finding PDFSHXTEXT variable

Anonymous
Not applicable

Trying to write a LISP routine that rotates the UCS automatically so the PDFSHXTEXT command can do its magic. Works for a certain rotation, but I want to expand the functionality by adding some conditional statements.

 

I need the variable name of whatever the PDFSHXTEXT command returns as far as the number of text objects created once the command is executed, so that IF that is equal to zero, I can have my routine try another set of modified commands, else have the user specify the UCS. Is there a way to look at the code for internal AutoCAD commands? Or does someone happen to know what variable stores returned values for commands?

0 Likes
1,243 Views
4 Replies
Replies (4)
Message 2 of 5

Ranjit_Singh
Advisor
Advisor

Something like this may work. Maybe there is some variable that stores that data but I am not aware of it. I got the last prompt idea from @ВeekeeCZ post over here.

(defun c:somefunc  (/ ss1)
  (setq ss1 (ssget))
  (command "pdfshxtext" ss1 "")
  (princ (if (= 0 (read (getvar 'lastprompt)))
           "\nTake other actions"
           "\nNo other action needed"))
  (princ))

pdfshxtext.gif

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

Modified my code with the getvar 'lastprompt idea.

 

(defun c:SIDETXTFIX (/ SEL)
 (command ".ucs" "z" "90")		;rotate coord sys
 (setq SEL (ssget))				;get user selection
 (command ".pdfshxtext" SEL "")	;convert to text
 (if (= 0 (read (getvar 'lastprompt)));IF fail to create any text objects
	(progn								;rotate axis 180 deg and try again
	 (command ".ucs" "z" "270")
	 (command ".pdfshxtext" SEL "")
	 );end progn
	(progn								;else have user select object to align ucs to
	 (command ".ucs" "object")
	 (command ".pdfshxtext" SEL "")
	 );end progn
  );end IF
 (command ".ucs" "")			;return to default coord sys
)

Couple issues -- routine seems to fail both the THEN and ELSE statements. I have test objects for both orientations and manually entering the ucs changes and pdfshxtext command produce text objects. Not sure what is going on.

0 Likes
Message 4 of 5

Ranjit_Singh
Advisor
Advisor

@Anonymous wrote:

Modified my code with the getvar 'lastprompt idea.

 

(defun c:SIDETXTFIX (/ SEL)
 (command ".ucs" "z" "90")		;rotate coord sys
 (setq SEL (ssget))				;get user selection
 (command ".pdfshxtext" SEL "")	;convert to text
 (if (= 0 (read (getvar 'lastprompt)));IF fail to create any text objects
	(progn								;rotate axis 180 deg and try again
	 (command ".ucs" "z" "270")
	 (command ".pdfshxtext" SEL "")
	 );end progn
	(progn								;else have user select object to align ucs to
	 (command ".ucs" "object")
	 (command ".pdfshxtext" SEL "")
	 );end progn
  );end IF
 (command ".ucs" "")			;return to default coord sys
)

Couple issues -- routine seems to fail both the THEN and ELSE statements. I have test objects for both orientations and manually entering the ucs changes and pdfshxtext command produce text objects. Not sure what is going on.


You may need to post your dwg file. One issue I see in the else block is you do not end the command for ucs. AutoCAD needs an object and you call ".pdfshxtext" Fix that and see if it helps.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Alright, added some setq statements to the then/else parts. The routine doesn't seem to evaluate the IF condition properly since executing my SIDETXTFIX command asks for an object selection twice for the default rotation case. Here's the code

 

(defun c:SIDETXTFIX (/ SEL)
 (command ".ucs" "z" "90")
 (setq SEL (ssget))
 (command ".pdfshxtext" SEL "")
 (if (= 0 (read (getvar 'lastprompt)))
	(progn
	 (command ".ucs" "z" "270")
	 (setq SEL (ssget))
	 (command ".pdfshxtext" SEL "")
	 );end progn
	(progn
	 (command ".ucs" "object" "")
	 (setq SEL (ssget))
	 (command ".pdfshxtext" SEL "")
	 );end progn
  );end IF
 (command ".ucs" "")
)

Also, attached my test drawing if anyone wants to play around

0 Likes