Jump to content

Recommended Posts

Posted

Hi,

I'm trying to create a macro that will replace Acad's current system of creating a temporary reference point, which involves typing "from" selecting a base point, then typing "@" and giving relative coordinates. I use temporary reference points all the time and it is a waste of time to constantly type out "from+@" I would like to simply use a shortcut key, select a basepoint, and then type in a relative coordinate, without ever having typed "@". So far, I've only gotten this macro to work: _from; but what I've been trying to get is something more like this: _from;\@ I'm not sure why this doesn't work...

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • gruedi

    11

  • Lee Mac

    10

  • CarlB

    2

  • SEANT

    2

Top Posters In This Topic

Posted

I believe AutoCAD will automatically place an "enter" (space) at the end of any macro, unless you use a special control character. Something like "^Z", not sure but you could look it up.

 

Also if you're using 2006 or layer you can just change your dynamic input mode and relative coordinates are always assumed.

..but probably not a good thing?

Posted

Yes, I would think that dynamic input would solve the problem, but for some reason Acad assumes absolute coordinates when within the temporary reference point command.

Posted
but what I've been trying to get is something more like this: _from;\@ I'm not sure why this doesn't work...

 

The macro you posted:

 

_from;\@

 

works well for me - just make sure that you don't prefix it with ^C^C, or any form of ^C. As this cancels all commands before invoking the macro.

Posted

Lee Mac, when you use the macro, do you have to tell AutoCad "@" to get it to switch to relative coordinates when within this macro?

 

Here's what happens when I use it:

Say I want to create a line with its first point 1 unit, 1 unit from an existing point within the drawing. I type "L-enter" then type my shortcut key (ctrl-t), at which point the computer asks for a base point (all is good so far). Now, if the macro was working properly, I would be able to type 1,1 (enter) and my first point of the line would be located 1,1 from the base point I specified. Instead, the computer reverts to absolute coordinates and puts the first point at 1,1 in absolute coordinates. I don't understand why this is such an issue for AutoCad, because I am in dynamic input and every other command works like it should (no @ sign needed).

Posted

Ahh yes, I see what you mean - sorry, I don't think I tested it properly.

 

I just saw that it prompted for a base point, and then I was able to specify a next point.

 

I think I know why this is happening - the "_from" is printed to the command line and the and the pause is activated so that the user can specify a base point. But, the "@" is not actually printed to the command line, as I don't think you can print something and have a pause at the same time in the macro.

 

With LISP it would be quite easy, just using a simple "strcat", but obviously, using LT, this won't be available to you.

Posted

Actually, could you elaborate on the Lisp idea? I should note that while I mainly use LT, I also have access to the full version.

Posted

Well just something like this would do I should think:

 

(defun c:refpnt ()
 (command "_from" pause)
 (command (strcat "@" (getstring "\nSpecify Next Point: "))))

 

But it will have to be run "transparently" within the command you are issuing.

 

i.e.

 

'refpnt

Posted

gruedi,

Here is a lisp that may work for you. If you assign REF to a function key, it saves some keystrokes over the method of drawing, then moving incrementally. Unfortunately, it's not what you had in mind - using a macro inside of a drawing command, and I don't think this lisp will work inside a command either. Sorry, it's far from an ideal solution.

 

; ref.lsp - sets a reference point to use with a relative ( @ ) dimension offset
;           for any subsequent drawing command.
;           Use : Type REF at the command line (or assign REF to a function key)
;           and pick a reference point. Then start a drawing command and use @x,y
;           or @x,y,z for the start point, center, etc.

(defun c:ref (/ *ERROR* rpt refset gset osave)
 (defun *ERROR* (msg) 
 (setvar "OSMODE" osave)
 (princ " - interrupted function ")
 (princ)
 )  
(setq osave (getvar "OSMODE"))
(setvar "OSMODE" 37) ; set end point, center and intersection snaps
(setvar "CMDECHO" 0)
(setq rpt (getpoint "\n Select reference point"))
(command ".POINT" rpt)
(setvar "CMDECHO" 1)
(setq refset (ssget "L"))
(sssetfirst gset refset)
(entdel (entlast))
(setq refset nil)
(setvar "OSMODE" osave)
(princ)
)

Posted

Thanks so much for the lisp programs. So there is no way to create a command to run "transparently" within another command? I mean, autocad does it somehow, since "from" works as well as "@". I suppose the other option is that dynamic input could be somehow turned on within the temporary reference point command, which it should be anyway. Maybe this is a glitch that Autodesk should be aware of.

Posted
So there is no way to create a command to run "transparently" within another command?

 

Yes, as I have said in a previous post, you can run a command transparently by using an apostrophe when calling the function.

 

i.e

 

Save my posted LISP, and in the button macro box, put 'refpnt

Posted

Hmmm. I think I see an error in our thinking. I just tried Lee Mac's lisp, but for some reason, the "@" part doesn't work for the first part of the command. In other words, "from" contains within it a series of two inputs, first, the base point, and second the offset. When we put the @ symbol after "from", it works for creating the second line point, but not the initial offset. We have to figure out some way to 'insert' the @ into "from." I'm not a Lisp programmer in any way, but I'm wondering if there is any way to create a program that recreates "from" (without relying on Autocad's "from") and assumes relative input for the offset distance. Thanks!

Posted

That sounds doable, to replicate the 'from', with a transparent lisp.

 

Shooting from the hip:

 

(defun c:ref ()
 (setq refpt (getpoint "Select reference point: "))
 (setq Off_distx (getreal "\nX offset from reference: "))
 (setq Off_disty (getreal "\nY offset from reference: "))
 (list (+ (car refpt) Off_distx) (+ (cadr refpt) Off_disty))
)

 

Now where you would type from instead use 'ref including the apostrophe.

 

Some others may want to spiff up that code. With some work you can have it allow "x,y" input rather than x and y separately.

Posted

For a x,y input, as Carl suggests...

 

 

(defun c:ref (/ refpt Off_dist Off_distx Off_disty)
 (setq refpt (getpoint "\nSelect reference point: ")
   Off_dist (getstring "\nOffset: ")
   Off_distx (substr Off_dist 1 (vl-string-position 44 Off_dist))
   Off_disty (substr Off_dist (+ 2 (vl-string-position 44 Off_dist))))
 (alert Off_disty)
(list (+ (car refpt) (atof Off_distx)) (+ (cadr refpt) (atof Off_disty)))
)

Posted

Cool! Now one last thing. Thanks for your patience so far. I work mainly in imperial architectural units. The program works perfectly except that I would have to enter in decimal units. Is there any way to switch this?

Posted

Maybe this:

 

(defun c:ref (/ refpt Off_dist Off_distx Off_disty)
 (setq refpt (getpoint "\nSelect reference point: ")
   Off_dist (getstring "\nOffset: ")
   Off_distx (substr Off_dist 1 (vl-string-position 44 Off_dist))
   Off_disty (substr Off_dist (+ 2 (vl-string-position 44 Off_dist))))
(list (+ (car refpt) (distof Off_distx 4)) (+ (cadr refpt) (distof Off_disty 4))))

Don't worry, we'll be patient :)

Posted

Beautiful. You don't know how much easier this makes my life (and probably some other people's as well).

Posted
Beautiful. You don't know how much easier this makes my life (and probably some other people's as well).

 

Ahh thanks Gruedi :) Happy to help. Any other questions, ask away :)

Posted

I've noticed a rather interesting glitch with this program that seems to be dependent on how far zoomed in you are in the drawing. When I use small units relative to the zoom distance, the reference point seems to become the base point. I don't just mean it looks like that because of the distance zoomed out. As an example, if I try to draw a line 1,1 from a base point when zoomed in, everything works fine. If I zoom out a good distance, and try again, then my first line point ends up at the base point (I zoom in to verify this). The weird thing is, the Lisp program seems to understand perfectly where the reference point should be. The command line shows the absolute coordinates for the reference point, and in both the zoomed in and zoomed out case, the command line coordinates appear identical. The entity properties show otherwise, showing that the actual coordinates in the drawing are different. Something seems to happen in between the calculations that the program does and what AutoCad draws.

Posted

Sounds like an OSNAP problem tbh - as an experiment, try switching off the osnaps (F3), and perform the same task and see if it still occurs.

 

Just a thought :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...