PDA

View Full Version : Some Handy Macros



dfitzpatrick
2006-04-13, 01:33 PM
Here's some handy little macros I use in some custom menus and toolbars.

Open location of current drawing in explorer
^C^C^P(startapp "explorer" (strcat "/e, "(getvar "dwgprefix")))(princ);

Select mid point between two points
_non;'cal;(cur+cur)/2;

Saveas 2000
^C^C^P(setq odwgname (getvar "dwgname"));(setq xdwgpath (getvar "dwgprefix"));(setq ndwgname (strcat (substr odwgname 1 (- (strlen odwgname) 4))));_saveas;2000;(strcat xdwgpath ndwgname);y;(command "close");y;

A crude but quick way of removing z values
C^C_move;_all;;0,0,0;0,0,1e99;_move;_p;;0,0,0;0,0,-1e99;

Draworder hatch to back
^C^C^p(setq ss1 (ssget "x" '((0 . "hatch"))));(command "_draworder" ss1 "" "_b");

girishpongalil
2006-04-15, 12:08 PM
Is there any way I can use these macros other than putting in mns file ?

Useful indeed.

jaberwok
2006-04-15, 03:40 PM
Is there any way I can use these macros other than putting in mns file ?

Useful indeed.


Macros are usually applied to buttons. You can create buttons without manually editing any file but the method varies according to the version of acad involved.

Augi Doggie
2006-04-15, 05:43 PM
I absolutely love the Explorer one!

The Midpoint Between Two Points macro is great for 2004 or earlier users. But I should point out that Midpoint Between Two Points (M2P) is (M2@P)is) available in AutoCAD 2005 and above as a OSnap.

In 2007 you can use the OSnap by entering either MTP or M2P.

madcadder
2006-04-15, 08:05 PM
This is probably the one I use the most for working views, saving views, center viewports, etc.



;;; by Pat Starkey, AUGI LISP Guild, 07/13/01
;;; Zooms to the extents of the current display
(defun c:zde (/ |displayextents|)
(setvar "cmdecho" 0)
(setq |displayextents|
(acet-geom-ss-extents
(ssget "c" (getvar "vsmin") (getvar "vsmax"))
t
)
)
(command "zoom"
"w"
(car |displayextents|)
(cadr |displayextents|)
)
(setvar "cmdecho" 1)
(princ)
)

dfitzpatrick
2006-04-20, 10:44 AM
I absolutely love the Explorer one!

The Midpoint Between Two Points macro is great for 2004 or earlier users. But I should point out that Midpoint Between Two Points (M2P) is (M2@P)is) available in AutoCAD 2005 and above as a OSnap.

In 2007 you can use the OSnap by entering either MTP or M2P.

Yeah I should have pointed that out, I'm still using 2004 in work unfortunately.

drinkamonster
2006-05-09, 07:47 PM
hey everyone! first post here..

i was browsing through and i found this sweet little script:

" Open location of current drawing in explorer
^C^C^P(startapp "explorer" (strcat "/e, "(getvar^M;"dwgprefix")))(princ); "

that works great, and i shared it with some guys in the office, and they were asking me to find a way to make another macro to open a certain folder in explorer, like a shortcut. we were wondering how to make a button to open explorer then browse to our personal folder. the directory is " K:\SDeily "

i have been attempting to do this myself but lack very much programming experience. the closest i could get on my own was with this:

" ^C^C^P(startapp "explorer")(princ); "

this script only opens the default explorer directory of 'my documents'.
any help here would be much appreciated! thanks

Opie
2006-05-09, 08:43 PM
hey everyone! first post here..

i was browsing through and i found this sweet little script:

" Open location of current drawing in explorer
^C^C^P(startapp "explorer" (strcat "/e, "(getvar^M;"dwgprefix")))(princ); "

that works great, and i shared it with some guys in the office, and they were asking me to find a way to make another macro to open a certain folder in explorer, like a shortcut. we were wondering how to make a button to open explorer then browse to our personal folder. the directory is " K:\SDeily "

i have been attempting to do this myself but lack very much programming experience. the closest i could get on my own was with this:

" ^C^C^P(startapp "explorer")(princ); "

this script only opens the default explorer directory of 'my documents'.
any help here would be much appreciated! thanks
What is your user name for ACAD? Is SDeily it? Then try this code.

^C^C^P(startapp "explorer" (strcat "/e, k:\\" (getvar "loginname")))(princ); "

drinkamonster
2006-05-10, 11:26 AM
What is your user name for ACAD? Is SDeily it? Then try this code.

^C^C^P(startapp "explorer" (strcat "/e, k:\\" (getvar "loginname")))(princ); "

i'm not sure what you mean by user name for ACAD.. i don't have to log in to that or anything. the script you sent didn't seem to do anything. is there a way to replace the "getvar" with something like an insert or run command to a certain directory?

Opie
2006-05-10, 02:50 PM
i'm not sure what you mean by user name for ACAD.. i don't have to log in to that or anything. the script you sent didn't seem to do anything. is there a way to replace the "getvar" with something like an insert or run command to a certain directory?
Yes, it can be changed to pretty much anything.

Is SDeily the same folder for everyone?

^C^C^P(startapp "explorer" "/e, k:\\SDeilly")(princ);

H-Angus
2006-05-10, 04:00 PM
Here's some handy little macros I use in some custom menus and toolbars.

Open location of current drawing in explorer
^C^C^P(startapp "explorer" (strcat "/e, "(getvar^M;"dwgprefix")))(princ);

Select mid point between two points
_non;'cal;(cur+cur)/2;

Saveas 2000
^C^C^P(setq odwgname (getvar "dwgname"));(setq xdwgpath (getvar "dwgprefix"));(setq ndwgname (strcat (substr odwgname 1 (- (strlen odwgname) 4))));_saveas;2000;(strcat xdwgpath ndwgname);y;(command "close");y;

A crude but quick way of removing z values
C^C_move;_all;;0,0,0;0,0,1e99;_move;_p;;0,0,0;0,0,-1e99;

Draworder hatch to back
^C^C^p(setq ss1 (ssget "x" '((0 . "hatch"))));(command "_draworder" ss1 "" "_b");


Cool, the explorer one is fantastic.

drinkamonster
2006-05-11, 03:30 PM
I don't know why but the other script with the k:\\ doesn't do anything again. The first explorer macro on this forum does work properly but the others won't seem to take. Do you think it might have something to do with me being on 2004 rather than 2006 or 2007? It's really not the most important macro but it's proving to be sort of difficult to get running. The last one you send me doesn't even open the explorer window for some reason.

cwade
2006-05-23, 08:37 PM
Try:
^C^C^P(startapp "explorer" (strcat "/e, ""k:\\"(getvar^M;"loginname")))(princ);
The above code will read your windows login name and open that directory or try:

^C^C^P(startapp "explorer" (strcat "/e, " "k:/SDeily/")))(princ);
Note in the line above they are / instead of \
or

^C^C^P(startapp "explorer" (strcat "/e, " "k:\\SDeily\\")))(princ);
Note in the line above there must be two \ in a row to look like \\

Both should work though, basically you can't have a single \, because of how AutoCAD handles these things, the \ has it's own meaning.