| Author |
Message |
j buzbee
Guest
|
Posted:
Tue Jan 04, 2005 10:53 pm Post subject:
Speed freaks . . . |
|
|
.. . . the ones that want to cut keystrokes not milliseconds off run times.
Every so often I'm editing a drawing with an Xref only there for reference.
So I'm constantly loading and unloading it throughout the editing session.
I wanted a really quick way to load and unload xrefs and thought a shortcut
menu like osnaps would be cool - so this is what I came up with:
You need to have a partial menu loaded with the menugroup name of "jb40".
If you have a custom partial menu just change the menugroup string in the
jb:XrefPop routine.
;;; Return a list of Xrefs
;;; use(setq l(jb:ListXrefs))
(defun jb:ListXrefs (/ xreflist)
(vlax-for
x (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (= (vlax-get-property x 'isxref) :vlax-true)
(setq xreflist (append xreflist (list (vlax-get-property x 'name))))))
xreflist)
;;;
;;; (setq ret(jb:XrefPop "_unload"))
;;; Returns the Shortcut menu object if found
(defun jb:XrefPop (oper / acadobj jbthisdrawing menugrps menu menus
shortcut xreflist)
(vl-load-com)
(setq acadobj
(vlax-get-acad-object)
jbthisdrawing
(vla-get-ActiveDocument acadobj)
menugrps
(vla-get-menugroups acadobj)
menu (vl-catch-all-apply 'vla-item (list menugrps "jb40"))); change the
menugroup here
; make sure the menugroup exists
(if (not (vl-catch-all-error-p menu))
(progn (setq menus (vla-get-menus menu))
(vlax-for
i menus
(if (= (vla-get-shortcutmenu i) :vlax-true) ; find the shortcut menu
(setq shortcut i)))
(if shortcut
(progn (vlax-for ii shortcut (vla-delete ii)) ; clean the shortcut
menu
(setq xreflist
(jb:ListXrefs) ; get a list of xrefs
cnt 0)
;populate the shortcut menu
(foreach
x xreflist
(vlax-invoke
shortcut
'addmenuitem
cnt
x
(strcat "-xref " oper " " (chr 34) x (chr 34) " "))
(setq cnt (1+ cnt)))))))
; return the shortcut menu object so we know to continue popping the menu!
shortcut)
;;; Unload
(defun c:jbUnloadXrefPop( / ret)
(setq ret(jb:XrefPop "_unload"))
(if ret
(progn(menucmd "P0=jb40.POP0")
(menucmd "P0=*"))
(alert "Menu not found!")))
;;; Reload
(defun c:jbReloadXrefPop( / )
(setq ret(jb:XrefPop "_reload"))
(if ret
(progn(menucmd "P0=jb40.POP0")
(menucmd "P0=*"))
(alert "Menu not found!")))
;;; Detach
(defun c:jbDetachXrefPop( / )
(setq ret(jb:XrefPop "_detach"))
(if ret
(progn(menucmd "P0=jb40.POP0")
(menucmd "P0=*"))
(alert "Menu not found!")))
;;;end
I've also got a pop for frozen layers and views. If anyone sees a way to
streamline anything, or if I missed localizing a variable let me know -
thanks.
jb
|
|
| Back to top |
|
 |
Kent Cooper, AIA
Guest
|
Posted:
Tue Jan 04, 2005 11:35 pm Post subject:
Re: Speed freaks . . . |
|
|
You could just Xref it into a distinct layer, and freeze that layer when you
don't want to see it.
--
Kent Cooper, AIA
"j buzbee" wrote...
| Quote: | . . . the ones that want to cut keystrokes not milliseconds off run times.
Every so often I'm editing a drawing with an Xref only there for
reference. So I'm constantly loading and unloading it throughout the
editing session. I wanted a really quick way to load and unload xrefs and
thought a shortcut menu like osnaps would be cool - so this is what I came
up with:
..... |
|
|
| Back to top |
|
 |
Tom Smith
Guest
|
Posted:
Wed Jan 05, 2005 12:18 am Post subject:
Re: Speed freaks . . . |
|
|
| Quote: | You could just Xref it into a distinct layer, and freeze that layer when
you don't want to see it. |
I agree, Ken -- though I'm curious as to his process. Why would you
constantly load and unload?
For most purposes, turning the xref layers off is good enough for me. I
used to have a button with the macro '-layer;off;*|*;; which is enough to do
that, regardless of the layer the xref is placed on.
|
|
| Back to top |
|
 |
j buzbee
Guest
|
Posted:
Wed Jan 05, 2005 12:24 am Post subject:
Re: Speed freaks . . . |
|
|
Yes, there are lots of ways to achieve unloading an xref. This is a
programming example for creating a shortcut menu "on the fly" and filling it
with whatever you want: a list of frozen layers to be thawed, views to be
restored, etc..
In this example one only needs to execute the command and the pull down menu
appears at the cursor location with a list of xrefs. Very, very quick.
jb |
|
| Back to top |
|
 |
Casey Roberts
Guest
|
Posted:
Wed Jan 05, 2005 1:21 am Post subject:
Re: Speed freaks . . . HELP! ... not werkin.. |
|
|
Okay, having trouble getting this to work.
I have my own partail menu loaded CASEY is the menu group name... I've changed it in the routine like you said however, it's still giving me the error that the menu doesn't exist. What am I missing?
"j buzbee" <jdb@journeysendfarm.net> wrote in message news:41dad813$1_2@newsprd01...
| Quote: | . . . the ones that want to cut keystrokes not milliseconds off run times.
Every so often I'm editing a drawing with an Xref only there for reference.
So I'm constantly loading and unloading it throughout the editing session.
I wanted a really quick way to load and unload xrefs and thought a shortcut
menu like osnaps would be cool - so this is what I came up with:
You need to have a partial menu loaded with the menugroup name of "jb40".
If you have a custom partial menu just change the menugroup string in the
jb:XrefPop routine.
;;; Return a list of Xrefs
;;; use(setq l(jb:ListXrefs))
(defun jb:ListXrefs (/ xreflist)
(vlax-for
x (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (= (vlax-get-property x 'isxref) :vlax-true)
(setq xreflist (append xreflist (list (vlax-get-property x 'name))))))
xreflist)
;;;
;;; (setq ret(jb:XrefPop "_unload"))
;;; Returns the Shortcut menu object if found
(defun jb:XrefPop (oper / acadobj jbthisdrawing menugrps menu menus
shortcut xreflist)
(vl-load-com)
(setq acadobj
(vlax-get-acad-object)
jbthisdrawing
(vla-get-ActiveDocument acadobj)
menugrps
(vla-get-menugroups acadobj)
menu (vl-catch-all-apply 'vla-item (list menugrps "CASEY"))); change the menugroup here
; make sure the menugroup exists
(if (not (vl-catch-all-error-p menu))
(progn (setq menus (vla-get-menus menu))
(vlax-for
i menus
(if (= (vla-get-shortcutmenu i) :vlax-true) ; find the shortcut menu
(setq shortcut i)))
(if shortcut
(progn (vlax-for ii shortcut (vla-delete ii)) ; clean the shortcut
menu
(setq xreflist
(jb:ListXrefs) ; get a list of xrefs
cnt 0)
;populate the shortcut menu
(foreach
x xreflist
(vlax-invoke
shortcut
'addmenuitem
cnt
x
(strcat "-xref " oper " " (chr 34) x (chr 34) " "))
(setq cnt (1+ cnt)))))))
; return the shortcut menu object so we know to continue popping the menu!
shortcut)
;;; Unload
(defun c:jbUnloadXrefPop( / ret)
(setq ret(jb:XrefPop "_unload"))
(if ret
(progn(menucmd "P0=jb40.POP0")
(menucmd "P0=*"))
(alert "Menu not found!")))
;;; Reload
(defun c:jbReloadXrefPop( / )
(setq ret(jb:XrefPop "_reload"))
(if ret
(progn(menucmd "P0=jb40.POP0")
(menucmd "P0=*"))
(alert "Menu not found!")))
;;; Detach
(defun c:jbDetachXrefPop( / )
(setq ret(jb:XrefPop "_detach"))
(if ret
(progn(menucmd "P0=jb40.POP0")
(menucmd "P0=*"))
(alert "Menu not found!")))
;;;end
I've also got a pop for frozen layers and views. If anyone sees a way to
streamline anything, or if I missed localizing a variable let me know -
thanks.
jb
|
|
|
| Back to top |
|
 |
Luis Esquivel
Guest
|
Posted:
Wed Jan 05, 2005 1:45 am Post subject:
Re: Speed freaks . . . HELP! ... not werkin.. |
|
|
| check the menucmd calls and use your group name there.... hth |
|
| Back to top |
|
 |
j buzbee
Guest
|
Posted:
Wed Jan 05, 2005 1:51 am Post subject:
Re: Speed freaks . . . HELP! ... not werkin.. |
|
|
Luis is right:
| Quote: | ;;; Unload
(defun c:jbUnloadXrefPop( / ret)
(setq ret(jb:XrefPop "_unload"))
(if ret
(progn(menucmd "P0=CASEY.POP0")
(menucmd "P0=*"))
(alert "Menu not found!"))) |
|
|
| Back to top |
|
 |
Matt Stachoni
Guest
|
Posted:
Wed Jan 05, 2005 1:55 am Post subject:
Re: Speed freaks . . . |
|
|
On Tue, 4 Jan 2005 14:18:43 -0500, "Tom Smith" <nospam> wrote:
| Quote: | You could just Xref it into a distinct layer, and freeze that layer when
you don't want to see it.
I agree, Ken -- though I'm curious as to his process. Why would you
constantly load and unload?
|
Because Xref Unloads are fast and frees up memory, for one. Important for very
large/busy Xrefs.
Secondly, unloading an Xref doesn't actually get rid of the Xref's Insert or
XClip information. Reloading the xref maintains the same base insertion point/
rotation/scale and xclip boundary.
Third, you also maintain your layer properties set in the Xref layers when it's
reloaded.
Matt
mstachoni@comcast.net
mstachoni@bhhtait.com |
|
| Back to top |
|
 |
Matt Stachoni
Guest
|
Posted:
Wed Jan 05, 2005 2:00 am Post subject:
Re: Speed freaks . . . |
|
|
On Tue, 4 Jan 2005 12:53:21 -0500, "j buzbee" <jdb@journeysendfarm.net> wrote:
| Quote: | . . . the ones that want to cut keystrokes not milliseconds off run times.
Every so often I'm editing a drawing with an Xref only there for reference.
So I'm constantly loading and unloading it throughout the editing session.
I wanted a really quick way to load and unload xrefs and thought a shortcut
menu like osnaps would be cool - so this is what I came up with:
|
Why are you even dealing with menus? Why not just create a some simple C:XD,
C:XU and C:XR command which will detatch/unload/reload Xrefs? You can assign
them to partial pop menus as you wish.
That would surely save some keystrokes off of someone trying to type in
jbUnloadXrefPop, jbReloadXrefPop, and jbDetachXrefPop if they don't like dealing
with menus (like me :).
Matt
mstachoni@comcast.net
mstachoni@bhhtait.com |
|
| Back to top |
|
 |
Anne Brown
Guest
|
Posted:
Wed Jan 05, 2005 2:04 am Post subject:
Re: Speed freaks . . . HELP! ... not werkin.. |
|
|
Here is a tip on using the discussion groups to your best
advantage. Please do not change the subject line of discussion
group messages to which you are replying. It breaks the ability
of the search engine to group the messages, makes it harder to
follow the thread and is quite confusing. If it is a new subject,
please start a new message; if a reply, put your text answer in
the body of your message and leave the header the same.
Thanks for your future cooperation.
---
Anne Brown
Discussion Groups Administrator
Autodesk, Inc.
| Quote: | Casey Roberts wrote:
Okay, having trouble getting this to work. (snip) |
|
|
| Back to top |
|
 |
j buzbee
Guest
|
Posted:
Wed Jan 05, 2005 2:13 am Post subject:
Re: Speed freaks . . . |
|
|
acad.pgp
UUX, *jbUnloadXrefPop
RRX, *jbReloadXrefPop
DDX, *jbDetachXrefPop
....
jbSaveCurrentProjectToFile, *jbSaveCurrentProjectToFile
(my longest command name - I think!)
I don't like menus either, that's why the attached code creates the Shortcut
Menu Object "on the fly". Here's one that populates the shortcut menu with
frozen layers:
(defun jb:LayerThawPop ( / acadobj jbthisdrawing menugrps menu
menugrps menus shortcut vlist cnt)
(vl-load-com)
(setq acadobj (vlax-get-acad-object)
jbthisdrawing(vla-get-ActiveDocument acadobj)
menugrps (vla-get-menugroups acadobj)
menu (vl-catch-all-apply 'vla-item (list menugrps "jb40"))); Change
menugroup here!!!
; make sure the menu is loaded
(if (not (vl-catch-all-error-p menu))
(progn (setq menus (vla-get-menus menu))
; find the shortcut menu
(vlax-for
i menus
(if (= (vla-get-shortcutmenu i) :vlax-true)
(setq shortcut i)))
(if shortcut
(progn
;clean out the shortcut menu
(vlax-for ii shortcut (vla-delete ii))
(setq cnt 0)
(vlax-for
v (vlax-get jbThisDrawing "layers")
(if (= (vla-get-freeze v) :vlax-true)
(setq vlist (append vlist (list (vla-get-name v))))))
;repopulate the shortcut menu
(foreach
x vlist
(vlax-invoke
shortcut
'addmenuitem
cnt
x
(strcat "-layer " "_thaw " (chr 34) x (chr 34) " "))
(setq cnt (1+ cnt)))))))
shortcut) |
|
| Back to top |
|
 |
j buzbee
Guest
|
Posted:
Wed Jan 05, 2005 2:32 am Post subject:
Re: Speed freaks . . . HELP! ... not werkin.. |
|
|
Ok, I included a POP0 menu in my partial, initially, but I didn't think it
would be needed. I quess it does . . . but I don't know why. Add something
like this:
***POP0
**JB
[&Used at Runtime]
ID_01 [Test]^C^C |
|
| Back to top |
|
 |
Tom Smith
Guest
|
Posted:
Wed Jan 05, 2005 2:42 am Post subject:
Re: Speed freaks . . . |
|
|
Thanks, Matt. In thinking about loading/unloading vs freezing the xref layer
vs turning off the xref's layers, I suppose the best approach depends on
your situation. As I understand it, unloading an xref is equivalent to
freezing it, in that it's "forgotten" for the purpose of regeneration. So
either of those methods would be beneficial for performance, if the xref is
large enough to bog you down.
On the other hand, I don't think memory is actually freed, in either of
those cases, unless you force a regen to flush the stuff from memory that
Acad is going to temporarily "forget." I haven't tested this since the days
when a regen was something you really wanted to avoid, but back then I think
you had to force the regen to gain the advantage. So it was a question of
whether the temporary performance gain was worth the extra regen. And in
either of these scenarios, to make the xref visible again, you have either
thaw its layer and force a regen, or reload the file, which amounts to about
the same thing. So there's effectively a regen to get the xref out of sight
(and gain memory) and another one to bring it back.
In turning xref layers off and on, you don't gain any memory, but you
neither do you cause a regen, going in either direction. In my usage, I'm
usually attaching a single xref, so I don't need to decide which one to
operate on, and they're usually not burdensome in size, so performance isn't
a major factor. Typically I'll freeze all the xref layers which aren't of
concern to me -- which does free some memory, when I regen again -- so I
don't lose any layer visibility properties by just turning all the "on" xref
layers off. I can put it back with a similar macro to turn them all on.
I think turning layers off and on is inherently faster than the other two
scenarios. It doesn't involve a performance gain, but that may not always be
a consideration. When xrefs first came along, doing a reload *always* caused
all your layer properties to be lost, regardless of the visretain setting,
so I avoided unload/reload like the plague, and learned to use either on/off
or freeze/thaw layer controls, depending on whether or not I wanted to gain
some performance at the expense of a regen. I'm not sure how long xref
reload has been fixed, but I don't think I heard about it until R14. |
|
| Back to top |
|
 |
Casey Roberts
Guest
|
Posted:
Wed Jan 05, 2005 2:56 am Post subject:
Re: Speed freaks . . . HELP! ... not werkin.. |
|
|
Slick... that did it... Thanks
"j buzbee" <jdb@journeysendfarm.net> wrote in message
news:41db0b84$1_2@newsprd01...
| Quote: | Ok, I included a POP0 menu in my partial, initially, but I didn't think
it
would be needed. I quess it does . . . but I don't know why. Add
something
like this:
***POP0
**JB
[&Used at Runtime]
ID_01 [Test]^C^C
|
|
|
| Back to top |
|
 |
Matt Stachoni
Guest
|
Posted:
Wed Jan 05, 2005 9:43 pm Post subject:
Re: Speed freaks . . . |
|
|
On Tue, 4 Jan 2005 16:42:46 -0500, "Tom Smith" <nospam> wrote:
| Quote: | On the other hand, I don't think memory is actually freed, in either of
those cases, unless you force a regen to flush the stuff from memory that
Acad is going to temporarily "forget."
|
As I understand it, unloading the Xref basically shuts off the valve leading to
the source file, and frees up the memory space used by AutoCAD to track all of
the Xref dependent objects in the DWg file. The only thing AutoCAD still tracks
is the Xref "insert" object itself and its properties, as well as Xclip info.
Reloading the Xref turns the valve on, so it reloads the info from the source
file and adds the data back into memory.
I haven't tested whether the regen was required, but it's possible that it's
needed to free up space in the display list. But that's only one part of the
total equation.
I've been using Xrefs both ways, and found unload/reload to have a slightly
bigger payoff from a performance standpoint (not so bad with modern machines),
but it's still really fast.
Personally I find Xref U/R MUCH easier to manage, because I don't have to worry
about putting an Xref on a specific layer (I always put mine on layer 0 through
some simple Xref macros). Also, I may stack multiple plan Xrefs on top of each
other to create an elevation; but may only want one floor on at a time. So I
would suggest that's mainly up to personal preference and how one uses Xrefs.
Matt
mstachoni@comcast.net
mstachoni@bhhtait.com |
|
| Back to top |
|
 |
|
|
|
|