PDA

View Full Version : Using getpoint help


dsolak
2006-02-24, 10:36 PM
(defun C:LEDAROW ()
(COMMAND "-layer" "s" "LDRS" "")
(command "LEADER" pause pause "" "" "NONE")
(setq pt (getpoint "Select first point:"))
(command "orthomode" "1")
(command "ucs" "new" "3point" "@" pause "")
(command "line" pt "@4.5024<0" "")
);defun

I need to make the getpoint the previous point with out picking it can someone help.

I might be doing the wrong command

[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

T.Willey
2006-02-24, 10:44 PM
To get the last point used in Acad, use
(getvar "lastpoint")

jwanstaett
2006-02-24, 10:45 PM
USE THE LASTPOINT System Variable

Type: 3D point
Not saved with drawing
Initial value: 0.0000,0.0000,0.0000
Stores the last point entered, expressed as a UCS coordinate for the current space; referenced by the at symbol (@) during keyboard entry.

To set the lastpoint
(SETVAR "LASTPOINT" PT)



To get the lastpoint
(setq pt (getvar "LASTPOINT"))

dsolak
2006-02-25, 12:02 AM
WHEN USING THIS:
(defun C:LEDAROW ()
(COMMAND "-layer" "s" "LDRS" "")
(command "LEADER" pause pause "" "" "NONE")
(SETVAR "LASTPOINT" PT)
(command "orthomode" "1")
(command "ucs" "new" "3point" "@" pause "")
(command "line" pt "@4.5024<0" "")
);defunCommand: ; error: AutoCAD variable setting rejected: "LASTPOINT" nil

PLEASE HELP

[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

.T.
2006-02-25, 12:53 AM
Hi,
I am not sure exactly what you are trying to do. I am assuming that your intent is to draw a leader and have a tag off of that leader at some angle 4.5024 units long.
See if one of these makes sense:
If you need the tag to just be flat (0 degrees), try:

(defun c:ledarow2 ( / pt1 pt2 pt3) ;Gives the function name and declares the variables local
(command "-layer" "m" "LDRS" "");Creates the layer or sets it current.
(setq pt1 (getpoint "Select first point:")) ;Gets the first point and stores it as pt1
(setq pt2 (getpoint pt1 "Select second point:"));Gets the second point and stores it as pt2
(command "LEADER" pt1 pt2 "" "" "NONE");Draws the leader
(setq pt3 (polar pt2 0.0 4.5024)) ;Stores the point 4.5024 units from pt2 at angle 0.
(command "line" pt2 pt3 "");Draws the line
(princ) ;Exits quietly
)

If you need the tag rotated, try:
(defun c:ledarow3 ( / pt1 pt2 pt3 ang) ;Gives the function name and declares variables
(command "-layer" "m" "LDRS" "");Creates the layer or sets it current.
(setq pt1 (getpoint "Select first point:"));Gets the first point and stores it as pt
(setq pt2 (getpoint pt1 "Select second point:")) ;Gets the second point and stores it as pt2
(command "LEADER" pt1 pt2 "" "" "NONE") ;Draws the leader
(setq ang (getangle pt2 "\nDirection: ")) ;Stores the angle for creating the line
(setq pt3 (polar pt2 ang 4.5024)) ;Stores the point that is 4.5024 units from pt2 at angle ang
(command "line" pt2 pt3 "") ;Draws the line
(princ) ;Exits quietly
)


If you need to actually move and rotate the ucs, add:
(command "ucs" "new" "3point" pt2 pt3 "")
just before the (princ) line on the one that rotates the tag.

Hope this helps,

rkmcswain
2006-02-25, 06:00 AM
To take all this one step further...


(defun c:ledarow3 ( / pt1 pt2)
(setq ocm (getvar "cmdecho") ol (getvar "clayer")) ;save current status
(setvar "cmdecho" 0) ;turn off cmdecho
(if (tblsearch "layer" "LDRS") ;see if layer exists
(command "._layer" "_T" "LDRS" "_ON" "LDRS" "_S" "LDRS" "");Thaws, turns on and sets desired layer current
(command "._layer" "_M" "LDRS" "");Creates the layer
)
(setq pt1 (getpoint "\nSelect first point: ")) ;Gets the first point and stores it as pt1
(setq pt2 (getpoint pt1 "\nSelect second point: "));Gets the second point and stores it as pt2
(command "._LEADER" pt1 pt2 "" "" "_N");Draws the leader
; No reason to create PT3 variable
(command "._line" pt2 (polar pt2 0.0 4.5024) "");Draws the line
(setvar "cmdecho" ocm) ;restore
(setvar "clayer" ol) ;restore
(princ) ;Exits quietly
)


Of course this could be taken even further to restore the frozen/off status of the layer, if that is what you desire. In that case, it makes more sense to just create the object with ActiveX or (entmake) and not worry about the current status of the layer, and having to restore it.