Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get last point of rotation

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
493 Views, 11 Replies

Get last point of rotation

I'm trying to get the last point that is picked when using the rotate command. I've tried (getvar "lastpoint") but it ends up being
the point the block was inserted. I'm drawing a blank here.

Here's my snippet of code below. Any help is appreciated.

(defun CreateHomerun ( / pt1 pt2 lts HR_group)
(setq lts (getvar "ltscale"))
(initget 1)
(while
(setq pt1 (getpoint "\n Pick first point of homerun.. "))
(command "-insert" "ghostblock" pt1 lts lts "")
(setq HR_group (ssadd))
(ssadd (entlast) HR_group)
(command "rotate" HR_group "" pt1 pause)
(setq pt2 (getvar "lastpoint")) ; gets insertion point of block instead
(command "line" pt1 pt2 "")
)
)

Thanks in advance.

Matt W
11 REPLIES 11
Message 2 of 12
mid-awe
in reply to: Anonymous

I've tried this as well but was beaten by LISP down to grabbing the angle of the finally rotated block and making use of that. Here is the one liner that counts, in case you need it. By the way thanks to Jeff Mishler for his guidance on this.

[code](COMMAND "-INSERT" block PT 1 1 "0")
(COMMAND "ROTATE" (ENTLAST) "" PT PAUSE)
(SETQ ang (/ (* 180 (cdr (assoc 50 (entget (entlast))))) pi))
(COMMAND "-INSERT" nextblock P1 1 1 ang)[/code]
Message 3 of 12
Anonymous
in reply to: Anonymous

So how did you get P1??

Matt W


wrote in message news:5147430@discussion.autodesk.com...
I've tried this as well but was beaten by LISP down to grabbing the angle of the finally rotated block and making use of that. Here
is the one liner that counts, in case you need it. By the way thanks to Jeff Mishler for his guidance on this.

[code](COMMAND "-INSERT" block PT 1 1 "0")
(COMMAND "ROTATE" (ENTLAST) "" PT PAUSE)
(SETQ ang (/ (* 180 (cdr (assoc 50 (entget (entlast))))) pi))
(COMMAND "-INSERT" nextblock P1 1 1 ang)[/code]
Message 4 of 12
Anonymous
in reply to: Anonymous

Here is our homerun code:


(defun DL_VAL (V TEMP)
(cdr (assoc V (entget TEMP)))
)

(defun C:HR ()

(command ".ARC" PAUSE "e" PAUSE "d" PAUSE)
(setq THIS_ARC (entlast))
(setq ARC_CENTER_PT (DL_VAL 10 THIS_ARC))
(setq LT_BASE (getvar "ltscale"))
(setq ARC_END_ANGLE_DIRECT (+ (DL_VAL 51 THIS_ARC) (/ pi 2)))
(setq ARC_END_ANGLE (getvar "lastangle"))
(setq LAST_PT (getvar "LASTPOINT"))
(setq ARC_RADIUS (DL_VAL 40 THIS_ARC))
(setq ARROW_LENGTH (* LT_BASE 0.09375))
(setq DELTA_ANGLE (/ ARROW_LENGTH ARC_RADIUS))

(setq ARC_CENTER_ANGLE (angle ARC_CENTER_PT LAST_PT))

(while (> ARC_END_ANGLE_DIRECT 0)
(setq ARC_END_ANGLE_DIRECT (- ARC_END_ANGLE_DIRECT (* 2 pi)))
)
(while (< ARC_END_ANGLE_DIRECT 0)
(setq ARC_END_ANGLE_DIRECT (+ ARC_END_ANGLE_DIRECT (* 2 pi)))
)
(while (> ARC_END_ANGLE 0)
(setq ARC_END_ANGLE (- ARC_END_ANGLE (* 2 pi)))
)
(while (< ARC_END_ANGLE 0)
(setq ARC_END_ANGLE (+ ARC_END_ANGLE (* 2 pi)))
)

(if (and (> ARC_END_ANGLE (- ARC_END_ANGLE_DIRECT 0.0005))
(< ARC_END_ANGLE (+ ARC_END_ANGLE_DIRECT 0.0005))
)
(setq ARC_CENTER_ANGLE (- ARC_CENTER_ANGLE DELTA_ANGLE))
(setq ARC_CENTER_ANGLE (+ ARC_CENTER_ANGLE DELTA_ANGLE))
)

(setq ARROW_ENDPOINT
(polar ARC_CENTER_PT ARC_CENTER_ANGLE ARC_RADIUS)
)
(setq TRUE_ANGLE (angle ARROW_ENDPOINT LAST_PT))

(setq ARROW_ANGLE (- (* (/ 180 pi) TRUE_ANGLE) 180))
(setq OSNAP-TEMP (getvar "osmode"))
(setvar "osmode" 0)
(command ".-INSERT" "ARROW" LAST_PT LT_BASE "" ARROW_ANGLE)
(setvar "osmode" OSNAP-TEMP)
(princ)
) ;
Message 5 of 12
Anonymous
in reply to: Anonymous

Try something like this (untested), saving pt2 as you pick it for the
rotation:

(command "rotate" HR_group "" pt1 (setq pt2 (getpoint "Rotation: ")))
(command "line" pt1 pt2 "")

--
Kent Cooper


"Matt W" wrote...
I'm trying to get the last point that is picked when using the rotate
command. I've tried (getvar "lastpoint") but it ends up being
the point the block was inserted. I'm drawing a blank here.

Here's my snippet of code below. Any help is appreciated.

(defun CreateHomerun ( / pt1 pt2 lts HR_group)
(setq lts (getvar "ltscale"))
(initget 1)
(while
(setq pt1 (getpoint "\n Pick first point of homerun.. "))
(command "-insert" "ghostblock" pt1 lts lts "")
(setq HR_group (ssadd))
(ssadd (entlast) HR_group)
(command "rotate" HR_group "" pt1 pause)
(setq pt2 (getvar "lastpoint")) ; gets insertion point of block
instead
(command "line" pt1 pt2 "")
)
)

Thanks in advance.

Matt W
Message 6 of 12
Anonymous
in reply to: Anonymous

Note: in the previous routine, it uses LT_BASE to store the LTSCALE for block scaling, and defines
ARROW_LENGTH with the length of the arrow head (it uses this to find out how far back on the arc to align the
arrow head).

So, if you uses another variable to store your drawing scale, or you uses a different size arrowhead, modify
those variables accordingly, as well as the name of your arrowhead block.
Message 7 of 12
Anonymous
in reply to: Anonymous

It works, but it doesn't show the ghosted image of what I'm rotating.
Got any other ideas??

Matt W


"Kent Cooper" wrote in message news:5147498@discussion.autodesk.com...
Try something like this (untested), saving pt2 as you pick it for the
rotation:

(command "rotate" HR_group "" pt1 (setq pt2 (getpoint "Rotation: ")))
(command "line" pt1 pt2 "")

--
Kent Cooper


"Matt W" wrote...
I'm trying to get the last point that is picked when using the rotate
command. I've tried (getvar "lastpoint") but it ends up being
the point the block was inserted. I'm drawing a blank here.

Here's my snippet of code below. Any help is appreciated.

(defun CreateHomerun ( / pt1 pt2 lts HR_group)
(setq lts (getvar "ltscale"))
(initget 1)
(while
(setq pt1 (getpoint "\n Pick first point of homerun.. "))
(command "-insert" "ghostblock" pt1 lts lts "")
(setq HR_group (ssadd))
(ssadd (entlast) HR_group)
(command "rotate" HR_group "" pt1 pause)
(setq pt2 (getvar "lastpoint")) ; gets insertion point of block
instead
(command "line" pt1 pt2 "")
)
)

Thanks in advance.

Matt W
Message 8 of 12
mid-awe
in reply to: Anonymous

Well, the point vars I was leaving for you. Just basic stuff such as:

(setq P1(getpoint "\n Pick a point to insert: "))

The part that you sounded like you needed was involving the ang var. But, I must have misunderstood. You are not interested in replicating the insertion angle?
Message 9 of 12
Anonymous
in reply to: Anonymous

Would a rubber-band showing where the eventual Line will go be enough for
you, even if it doesn't drag the stuff you're rotating? You can add a
rubber-band reference in (getpoint):

(command "rotate" HR_group "" pt1 (setq pt2 (getpoint pt1 "Rotation:
")))
(command "line" pt1 pt2 "")

--
Kent Cooper


"Matt W" wrote...
It works, but it doesn't show the ghosted image of what I'm rotating.
Got any other ideas??

Matt W


"Kent Cooper" wrote...
Try something like this (untested), saving pt2 as you pick it for the
rotation:

(command "rotate" HR_group "" pt1 (setq pt2 (getpoint "Rotation: ")))
(command "line" pt1 pt2 "")

--
Kent Cooper


"Matt W" wrote...
I'm trying to get the last point that is picked when using the rotate
command. I've tried (getvar "lastpoint") but it ends up being
the point the block was inserted. I'm drawing a blank here.

Here's my snippet of code below. Any help is appreciated.

(defun CreateHomerun ( / pt1 pt2 lts HR_group)
(setq lts (getvar "ltscale"))
(initget 1)
(while
(setq pt1 (getpoint "\n Pick first point of homerun.. "))
(command "-insert" "ghostblock" pt1 lts lts "")
(setq HR_group (ssadd))
(ssadd (entlast) HR_group)
(command "rotate" HR_group "" pt1 pause)
(setq pt2 (getvar "lastpoint")) ; gets insertion point of block
instead
(command "line" pt1 pt2 "")
)
)

Thanks in advance.

Matt W
Message 10 of 12
Anonymous
in reply to: Anonymous

Nope....
I want to get the last point selected when using the rotate command.
The angle part is easy.

Matt W
Message 11 of 12
Anonymous
in reply to: Anonymous


The rubber band is what I currently
use.

 

The reason I wanted to do some sort of ghosting is
so that the end-user would have an idea how much space would be taken up by
placing a homerun on an electrical drawing.  Some drawings can become
extremely congested.  The ghosting would help the user determine the best
location to place the homerun and whether or not the homerun will end up
overlapping some other critical piece of information making it harder to
read.

 

Basically what I want to do is this:

1) Pick a starting point PT1 (this would be
the tail end of the leader - the part connected to the receptacles shown in the
image). (this part I already have done)

2) Use some sort of ghosting (or a dummy block)
that would represent the approximate area that the homerun would be taken up.
(This is the part that is driving me crazy).

  I've looked into acet-ss-drag-rotate - which
works great - but I'm running into the same problem; I can't get the last point
- PT2 - selected when rotating.  I need that second point so I know where
to start the leader.

  When I use (setq pt2 (getvar
"lastpoint")) and then draw a line for example from PT1 to PT2 I get a zero
length line.

3) Draw the homerun leader and insert the
attributed block for amps, poles, panel, etc... (this part I have)

4) Delete the dummy block (easy enough to
do)

 

 

[img src="@105604"]

 

 

 

 

Would a rubber-band
showing where the eventual Line will go be enough for
you, even if it
doesn't drag the stuff you're rotating?  You can add a
rubber-band
reference in (getpoint):

      (command "rotate"
HR_group "" pt1 (setq pt2 (getpoint pt1 "Rotation:

")))
      (command "line" pt1 pt2
"")

--
Kent Cooper


"Matt W" wrote...
It works, but it
doesn't show the ghosted image of what I'm rotating.
Got any other
ideas??

Matt W


"Kent Cooper" wrote...
Try something like
this (untested), saving pt2 as you pick it for
the
rotation:

      (command "rotate"
HR_group "" pt1 (setq pt2 (getpoint "Rotation:
")))
      (command "line" pt1 pt2 "")

--

Kent Cooper


"Matt W" wrote...
I'm trying to get the last point
that is picked when using the rotate
command.  I've tried (getvar
"lastpoint") but it ends up being
the point the block was inserted.  I'm
drawing a blank here.

Here's my snippet of code below.  Any help is
appreciated.

(defun CreateHomerun ( / pt1 pt2 lts
HR_group)
   (setq lts (getvar "ltscale"))
   (initget
1)
   (while
      (setq pt1 (getpoint
"\n Pick first point of homerun.. "))
      (command
"-insert" "ghostblock" pt1 lts lts "")
      (setq
HR_group (ssadd))
      (ssadd (entlast)
HR_group)
      (command "rotate" HR_group "" pt1
pause)
      (setq pt2 (getvar "lastpoint")) ; gets
insertion point of block
instead
      (command
"line" pt1 pt2 "")
   )
)

Thanks in
advance.

 Matt W
Message 12 of 12
Anonymous
in reply to: Anonymous

Matt,

A shot in the dark since I only have a general idea of what your are trying to do.

As I understand acet-ss-drag-rotate, it returns the rotation angle in radians. As I
understand acet-ss-drag-move, it returns the point picked. So maybe you could use
drag-rotate first, then drag-move in some fashion to get the point you are looking
for.

Regarding your original question about lastpoint, from what I've seen the lastpoint
var is not updated when a point is picked in response to a command call within a lisp
routine. Which confirms what you found. In fact, I think the issue is more general
than that.

Command: (getvar "lastpoint")
(33415.4 -6632.55 0.0)
Command: (getpoint)
(29944.5 -6991.13 0.0)
Command: (getvar "lastpoint")
(33415.4 -6632.55 0.0)

Joe Burke


"Matt W" wrote in message news:5147708@discussion.autodesk.com...
The rubber band is what I currently use.

The reason I wanted to do some sort of ghosting is so that the end-user would have an
idea how much space would be taken up by placing a homerun on an electrical drawing.
Some drawings can become extremely congested. The ghosting would help the user
determine the best location to place the homerun and whether or not the homerun will
end up overlapping some other critical piece of information making it harder to read.

Basically what I want to do is this:
1) Pick a starting point PT1 (this would be the tail end of the leader - the part
connected to the receptacles shown in the ima ge). (this part I already have done)
2) Use some sort of ghosting (or a dummy block) that would represent the approximate
area that the homerun would be taken up. (This is the part that is driving me crazy).
I've looked into acet-ss-drag-rotate - which works great - but I'm running into the
same problem; I can't get the last point - PT2 - selected when rotating. I need tha
t second point so I know where to start the leader.
When I use (setq pt2 (getvar "lastpoint")) and then draw a line for example from
PT1 to PT2 I get a zero length line.
3) Draw the homerun leader and insert the attributed block for amps, poles, panel,
etc... (this part I have)
4) Delete the dummy block (easy enough to do)


[img src="@105604"]




"Kent Cooper" wrote in message
news:5147655@discussion.autodesk.com...
Would a rubber-band showing where the eventual Line will go be enough for
you, even if it doesn't drag the stuff you're rotating? You can add a
rubber-band reference in (getpoint):

(command "rotate" HR_group "" pt1 (setq pt2 (getpoint pt1 "Rotation:
")))
(command "line" pt1 pt2 "")

--
Kent Cooper


"Matt W" wrote...
It works, but it doesn't show the ghosted image of what I'm rotating.
Got any other ideas??

Matt W


"Kent Cooper" wrote...
Try something like this (untested), saving pt2 as you pick it for the
rotation:

(command "rotate" HR_group "" pt1 (setq pt2 (getpoint "Rotation: ")))
(command "line" pt1 pt2 "")

--
Kent Cooper


"Matt W" wrote...
I'm trying to get the last point that is picked when using the rotate
command. I've tried (getvar "lastpoint") but it ends up being
the point the block was inserted. I'm drawing a blank here.

Here's my sn ippet of code below. Any help is appreciated.

(defun CreateHomerun ( / pt1 pt2 lts HR_group)
(setq lts (getvar "ltscale"))
(initget 1)
(while
(setq pt1 (getpoint "\n Pick first point of homerun.. "))
(command "-insert" "ghostblock" pt1 lts lts "")
(setq HR_group (ssadd))
(s sadd (entlast) HR_group)
(command "rotate" HR_group "" pt1 pause)
(setq pt2 (getvar "lastpoint")) ; gets insertion point of block
instead
(command "line" pt1 pt2 "")
)
)

Thanks in advance.

Matt W

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report