Author Topic: vlr-commandWillStart  (Read 17052 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: vlr-commandWillStart
« Reply #45 on: March 21, 2011, 11:57:17 AM »
Quote
But surely just (LoadPageSetup) in the ACADDOC.lsp will perform as needed?

I thought so too, but (LoadPageSetup) did not work for me, it kept giving me a Unknown function

Is the 'LoadPageSetup' function defined before it is called?

EDIT: Also, how are you loading/defining the 'LoadPageSetup' function?
« Last Edit: March 21, 2011, 12:16:25 PM by Lee Mac »

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: vlr-commandWillStart
« Reply #46 on: March 21, 2011, 11:59:16 AM »
I've always seen and done as follows:

Code: [Select]
(defun-q MyStartup (/) BLAH BLAH)
(setq S::STARTUP (append S::STARTUP MyStartup))
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

cadman6735

  • Guest
Re: vlr-commandWillStart
« Reply #47 on: March 21, 2011, 12:39:27 PM »

I don't know what to say, I guess I was not holding my tounge the right way...  

(LoadPageSetup) with out the S::Startup works now.

the load function is after the call, the only thing I did different was save and close the acaddoc.lsp before running vs. just saving it then seeing if it worked.

I am not happy about this because all weekend I banged my head trying to figure this out when I could have been enjoying the sunshine.

But since I am here

What reason would you use S::STARTUP for, if you advise against using it.  Was it primarly for older versions of ACAD?

and

Is there a way to trick a reactor to use a command?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: vlr-commandWillStart
« Reply #48 on: March 21, 2011, 01:05:46 PM »
the load function is after the call...

I'm guessing you mean 'before' since otherwise the function wouldn't be defined when you call it...

What reason would you use S::STARTUP for, if you advise against using it.  Was it primarly for older versions of ACAD?

To be honest, I don't use it too much, but I would think it is due to the order in which acad/acaddoc/s::startup are evaluated, you can test this by adding a 'princ' call to each (printing a different message of course), and seeing what order the messages are printed.

Is there a way to trick a reactor to use a command?

No - but almost anything accomplished by a command can be coded in Visual LISP.

cadman6735

  • Guest
Re: vlr-commandWillStart
« Reply #49 on: March 21, 2011, 02:11:02 PM »
Quote
I'm guessing you mean 'before' since otherwise the function wouldn't be defined when you call it...

yes, this is what I mean...

Quote
I would think it is due to the order in which acad/acaddoc/s::startup are evaluated, you can test this by adding a 'princ' call to each (printing a different message of course), and seeing what order the messages are printed.

Nice, I will do this...

Quote
No - but almost anything accomplished by a command can be coded in Visual LISP.

Ok, I kept finding posts where people would say "you can do it this way" or "that way" with what seemed like posative feed back as if it worked.  I coudn't duplicate their method or technique, then I would find posts that bluntly say you can't call commands from a reactor,  so I was wondering if I was missing something.

cadman6735

  • Guest
Re: vlr-commandWillStart
« Reply #50 on: March 22, 2011, 08:56:41 AM »
This is where I found my information about the S::STARTUP function

One thing it states to why I believed the STARTUP function was for custom commands.
Quote
S::STARTUP function – This function is typically within the ACADDOC.LSP file (or ACAD.LSP file for AutoCAD R14 installations) and its sole job is to execute customized commands you need to initialize your new drawing environment.

http://www.cad-manager.com/archives/6

Another link is to the ACAD2010 help file and I found this interesting and maybe answers why my command was not running at startup, but I really don't know.  At home I am using ACAD2002 I wonder if this could be a cause of why my (LoadPageSetup) was not running at startup but would run after I typed in the (LoadPageSetup)...

Quote
The startup LISP files (acad.lsp, acaddoc.lsp, and MNL) are all loaded into memory before the drawing is completely initialized. Typically, this does not pose a problem, unless you want to use the command function, which is not guaranteed to work until after a drawing is initialized.

I wonder if this could also be a cause of why my (LoadPageSetup) was not running at startup but would run after I typed in the (LoadPageSetup) it does call a command...



http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/files/WS73099cc142f4875513fb5cd10c4aa30d6b-7f62.htm

BlackBox

  • King Gator
  • Posts: 3770
Re: vlr-commandWillStart
« Reply #51 on: March 29, 2011, 10:47:41 PM »
How does one successfully delete all named views, after deleting all existing page setups?

Code: [Select]
_$ (setq activeDoc (vla-get-activedocument (vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocument 18ec59d0>

_$ (vlax-for x  (vla-get-plotconfigurations activeDoc) (vla-delete x))
nil

_$ (vlax-for x  (vla-get-views activeDoc) (vla-delete x))
[color=red]; error: Automation Error. Object is referenced by other object(s)[/color]

_$

Note - After deleting all page setups, and prior to deleting all named views, I've set an arbitrary, non-view referencing page setup current <None> via the ._-plot command (not shown).

[edit]
Given that all existing page setups have been deleted, I've tried (vla-refreshplotdeviceinfo (vla-get-layout (vla-get-paperspace activeDoc))) to no avail.
[/edit]

The purpose being that the desired page setups to be imported reference a named view, which has been modified.

If the existing named views are not deleted prior to importing the new page setups, then the new page setup reference the existing named view, as the modified named view is not imported.

This did the trick:

Code: [Select]
(vl-cmdf "._-view" "delete" "*")
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: vlr-commandWillStart
« Reply #52 on: March 29, 2011, 10:51:04 PM »
This is where I found my information about the S::STARTUP function

One thing it states to why I believed the STARTUP function was for custom commands.
Quote
S::STARTUP function – This function is typically within the ACADDOC.LSP file (or ACAD.LSP file for AutoCAD R14 installations) and its sole job is to execute customized commands you need to initialize your new drawing environment.

http://www.cad-manager.com/archives/6

Another link is to the ACAD2010 help file and I found this interesting and maybe answers why my command was not running at startup, but I really don't know.  At home I am using ACAD2002 I wonder if this could be a cause of why my (LoadPageSetup) was not running at startup but would run after I typed in the (LoadPageSetup)...

Quote
The startup LISP files (acad.lsp, acaddoc.lsp, and MNL) are all loaded into memory before the drawing is completely initialized. Typically, this does not pose a problem, unless you want to use the command function, which is not guaranteed to work until after a drawing is initialized.

I wonder if this could also be a cause of why my (LoadPageSetup) was not running at startup but would run after I typed in the (LoadPageSetup) it does call a command...



http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/files/WS73099cc142f4875513fb5cd10c4aa30d6b-7f62.htm

Perhaps instead of using S::STARTUP, you could simply write a script to call (LoadPageSetup), and use the "/b" switch in a copy of the application icon, as the "/b" switch is executed after S::STARTUP, at the end of the load sequence?

Just a thought.
"How we think determines what we do, and what we do determines what we get."

cadpoobah

  • Newt
  • Posts: 48
Re: vlr-commandWillStart
« Reply #53 on: November 23, 2016, 03:10:14 PM »
All,

I know this is an old post, but just thought I would toss out an issue I had with some of the code shared above and see if there was any advice.

I started using the copy_page-setup function (in lieu of the "_PSETUPIN" command) during my Startup. Seemed to work fine but then we started having issue with Publish. It seems that the page setup, while it appeared to be imported successfully, wasn't "seen" correctly by the Publish command. Even though the Publish dialog showed the correct page setup name, it would error and VIEWPLOTDETAILS woudl return "ERROR: Page setup not found".

I found the same (albeit using VB.Net) issue on here : https://www.theswamp.org/index.php?topic=50733.0.

I've since reverted back to the _PSETUPIN command and things seem fine, but I would prefer to use the DBX method.

Any thoughts?
Chris Lindner
Onebutton CAD Solutions
----------------------------------------------------
www.onebuttoncad.com #dayjob
www.unpavedart.com    #sidehustle