Autolisp Mouse Left Click?

Autolisp Mouse Left Click?

anieves228
Enthusiast Enthusiast
1,179 Views
5 Replies
Message 1 of 6

Autolisp Mouse Left Click?

anieves228
Enthusiast
Enthusiast

Hello all,

 

I am trying to initiate or simulate a left mouse click. Similar to "" for spacebar/enter. Is this possible? I cant find much on this.

 

Thank you!

0 Likes
Accepted solutions (1)
1,180 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

Can you just give it XY coordinates?  That's what would be returned by a left-click when in a command that's looking for a location.  If you mean it for object selection by having the routine find something at a given location without your needing to pick on it, look into (nentselp), which can pick an object for you given the coordinates of where to pick it.  [For some reason there's no non-nested (entselp) function, but (nentselp) will see a top-level object if it's not nested.]  Or do you have some other kind of left-click purpose in mind?

Kent Cooper, AIA
0 Likes
Message 3 of 6

anieves228
Enthusiast
Enthusiast

My application is rather simple. Really just placing a text box. I did it with single-line text (as shown below). The command places text at the appropriate size and with the proper text style. I would like to do this with Multiline text. So all I would need is a left click for the second click for the text box size during the _mtext command. 

	(DEFUN C:T1 ()
    
  	(SETVAR "CMDECHO" 0)

		(C:TERRA01) ;Creates 0.1" Text style 
		(C:annoscale) ;Sets annotation scales

		(PROMPT "INSERT 0.1 TEXT")
 
      (SETVAR "CMDECHO" 0)
		
    (COMMAND "-LAYER" "M" "DWG-TEXT-GENERAL" "L" "CONTINUOUS" "" "LW" "0" "" "S" "0" "")
			(SETVAR "CLAYER" "DWG-TEXT-GENERAL")
			(COMMAND "TEXT" "S" "TERRA 0.1" PAUSE "0" "INSERT TEXT")
		(SETVAR "CMDECHO" 1)
		(PRINC)
	)

 

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

If you don't expect the Mtext to need to word-wrap, you can use the Width option and give it zero for the width, to avoid the need to pick a second point:

 

(COMMAND "_.MTEXT" pause "_style" "TERRA 0.1" "_width" 0 "INSERT TEXT" "")

 

Or if you have a known width for the text box, you can give it that with a relative displacement [only the X part matters]:

 

(COMMAND "_.MTEXT" pause "_style" "TERRA 0.1" "@4,0" "INSERT TEXT" "")

 

You just need to be aware of the sequence of prompts [for example, that you must pause for the first point before the Style option unlike in a TEXT command, and you must invoke the Style option before giving it the second point].

 

P.S.  If this:

(C:TERRA01) ;Creates 0.1" Text style

makes that Style current in the process, then you don't need to specify the Style within the Text/Mtext command.

Kent Cooper, AIA
0 Likes
Message 5 of 6

anieves228
Enthusiast
Enthusiast

Ah ok perfect! Thank you! 

 

This does not make the style current. it just creates it. I made this for it to be mainly called when I do other commands. Such as inserting a layout with a border template to make sure all the text has a style to reference. 

(C:TERRA01) ;Creates 0.1" Text style

 

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

If the function only creates the text style use

(C:TERRA01) ;Creates 0.1" Text style
(setvar 'textstyle "Your style name")
0 Likes