VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

acad.lsp + acaddoc.lsp clash

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
330 Views, 5 Replies

acad.lsp + acaddoc.lsp clash

I have read a lot of postings but I still can't quite find the answer to
this:-

I have a desktop icon which starts AutoCAD in a directory with the following
2 files:-

acad.lsp which contains the following

(defun S::STARTUP()
(command "_-vbaload" "StoreSpace.dvb")
(command "_-VBARUN" "Initialise")
)

and acaddoc.lsp which contains the following:-
(defun S::STARTUP()
(command "_-VBARUN" "Runsynchronise")
)

This produces the following error:-
"Command: -vbarun
Macro name: ShowFixtures Execution error"

and StoreSpace.dvb is not loaded.

If I move acaddoc.lsp, acad.lsp runs and loads StoreSpace.dvb but obviously
the ShowFixtures sub does not run, unless I move it back into the directory
after starting up AutoCAD in which case it runs on each drawing opening. I
don't understand why this causes a problem. I would expect acad.lsp to run
on startup then acaddoc.lsp to run on opening of each drawing.

Regards

Dave Preston
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Dave Preston wrote:
>
> I have a desktop icon which starts AutoCAD in a directory with the following
> 2 files:-
>
> acad.lsp which contains the following
>
> (defun S::STARTUP()
> (command "_-vbaload" "StoreSpace.dvb")
> (command "_-VBARUN" "Initialise")
> )
>
> and acaddoc.lsp which contains the following:-
> (defun S::STARTUP()
> (command "_-VBARUN" "Runsynchronise")
> )
>

Your "S::STARTUP" function in "acaddoc.lsp" is overwriting
the same function as defined in "acad.lsp"

"Acad.lsp" loads first, defining S::STARTUP.
Then "acaddoc.lsp" loads, redefining S::STARTUP.

Put all your startup code in a function called "mystartup",
(in "acaddoc.lsp") and append it to S::Startup, in case it's
already defined somewhere else...

(defun-q mystartup ()
(this is my startup code)
)
(setq S::STARTUP (append S::STARTUP mystartup))







--
R.K. McSwain
http://rkmcswain.blogspot.com
Message 3 of 6
Anonymous
in reply to: Anonymous

Many thanks. That works perfectly

Regards
Dave Preston

"R.K. McSwain" wrote in message
news:5813787@discussion.autodesk.com...
Dave Preston wrote:
>
> I have a desktop icon which starts AutoCAD in a directory with the
> following
> 2 files:-
>
> acad.lsp which contains the following
>
> (defun S::STARTUP()
> (command "_-vbaload" "StoreSpace.dvb")
> (command "_-VBARUN" "Initialise")
> )
>
> and acaddoc.lsp which contains the following:-
> (defun S::STARTUP()
> (command "_-VBARUN" "Runsynchronise")
> )
>

Your "S::STARTUP" function in "acaddoc.lsp" is overwriting
the same function as defined in "acad.lsp"

"Acad.lsp" loads first, defining S::STARTUP.
Then "acaddoc.lsp" loads, redefining S::STARTUP.

Put all your startup code in a function called "mystartup",
(in "acaddoc.lsp") and append it to S::Startup, in case it's
already defined somewhere else...

(defun-q mystartup ()
(this is my startup code)
)
(setq S::STARTUP (append S::STARTUP mystartup))







--
R.K. McSwain
http://rkmcswain.blogspot.com
Message 4 of 6
Anonymous
in reply to: Anonymous

Hmm. Although everything works perfectly I have just noticed that I get the
following error when starting AutoCAD if the acaddoc.lsp is present:-

AutoCAD menu utilities loaded.; error: Invalid attempt to access a compiled
function definition. You may want to define it using defun-q: #
@0f40ee38
S::STARTUP>


My acad.lsp contains the following:-
(defun S::STARTUP()
(command "_-vbaload" "StoreSpace.dvb")
(command "_-VBARUN" "Initialise")
)

My acaddoc.lsp contains the following:-
(defun-q docStartup()
(command "-VBARUN" "Runsynchronise")
)
(setq S::STARTUP (append S::STARTUP docStartup))

"R.K. McSwain" wrote in message
news:5813787@discussion.autodesk.com...
Dave Preston wrote:
>
> I have a desktop icon which starts AutoCAD in a directory with the
> following
> 2 files:-
>
> acad.lsp which contains the following
>
> (defun S::STARTUP()
> (command "_-vbaload" "StoreSpace.dvb")
> (command "_-VBARUN" "Initialise")
> )
>
> and acaddoc.lsp which contains the following:-
> (defun S::STARTUP()
> (command "_-VBARUN" "Runsynchronise")
> )
>

Your "S::STARTUP" function in "acaddoc.lsp" is overwriting
the same function as defined in "acad.lsp"

"Acad.lsp" loads first, defining S::STARTUP.
Then "acaddoc.lsp" loads, redefining S::STARTUP.

Put all your startup code in a function called "mystartup",
(in "acaddoc.lsp") and append it to S::Startup, in case it's
already defined somewhere else...

(defun-q mystartup ()
(this is my startup code)
)
(setq S::STARTUP (append S::STARTUP mystartup))







--
R.K. McSwain
http://rkmcswain.blogspot.com
Message 5 of 6
Anonymous
in reply to: Anonymous

You need to used defun-q for your s::startup too. This will allow the append
to work.

Dave Preston wrote:
> Hmm. Although everything works perfectly I have just noticed that I get the
> following error when starting AutoCAD if the acaddoc.lsp is present:-
>
> AutoCAD menu utilities loaded.; error: Invalid attempt to access a compiled
> function definition. You may want to define it using defun-q: #
> @0f40ee38
> S::STARTUP>
>
>
> My acad.lsp contains the following:-
> (defun S::STARTUP()
> (command "_-vbaload" "StoreSpace.dvb")
> (command "_-VBARUN" "Initialise")
> )
>
> My acaddoc.lsp contains the following:-
> (defun-q docStartup()
> (command "-VBARUN" "Runsynchronise")
> )
> (setq S::STARTUP (append S::STARTUP docStartup))
>
> "R.K. McSwain" wrote in message
> news:5813787@discussion.autodesk.com...
> Dave Preston wrote:
>> I have a desktop icon which starts AutoCAD in a directory with the
>> following
>> 2 files:-
>>
>> acad.lsp which contains the following
>>
>> (defun S::STARTUP()
>> (command "_-vbaload" "StoreSpace.dvb")
>> (command "_-VBARUN" "Initialise")
>> )
>>
>> and acaddoc.lsp which contains the following:-
>> (defun S::STARTUP()
>> (command "_-VBARUN" "Runsynchronise")
>> )
>>
>
> Your "S::STARTUP" function in "acaddoc.lsp" is overwriting
> the same function as defined in "acad.lsp"
>
> "Acad.lsp" loads first, defining S::STARTUP.
> Then "acaddoc.lsp" loads, redefining S::STARTUP.
>
> Put all your startup code in a function called "mystartup",
> (in "acaddoc.lsp") and append it to S::Startup, in case it's
> already defined somewhere else...
>
> (defun-q mystartup ()
> (this is my startup code)
> )
> (setq S::STARTUP (append S::STARTUP mystartup))
>
>
>
>
>
>
>
Message 6 of 6
Anonymous
in reply to: Anonymous

Cheers Ken, I missed that subtle difference. It's not something I know much
about. That said, the first CAD programming I did was autolisp 22 years ago,
and not used it much since so a bit rusty now!

Dave

"Ken Krupa" wrote in message
news:5816824@discussion.autodesk.com...
You need to used defun-q for your s::startup too. This will allow the append
to work.

Dave Preston wrote:
> Hmm. Although everything works perfectly I have just noticed that I get
> the
> following error when starting AutoCAD if the acaddoc.lsp is present:-
>
> AutoCAD menu utilities loaded.; error: Invalid attempt to access a
> compiled
> function definition. You may want to define it using defun-q: #
> @0f40ee38
> S::STARTUP>
>
>
> My acad.lsp contains the following:-
> (defun S::STARTUP()
> (command "_-vbaload" "StoreSpace.dvb")
> (command "_-VBARUN" "Initialise")
> )
>
> My acaddoc.lsp contains the following:-
> (defun-q docStartup()
> (command "-VBARUN" "Runsynchronise")
> )
> (setq S::STARTUP (append S::STARTUP docStartup))
>
> "R.K. McSwain" wrote in message
> news:5813787@discussion.autodesk.com...
> Dave Preston wrote:
>> I have a desktop icon which starts AutoCAD in a directory with the
>> following
>> 2 files:-
>>
>> acad.lsp which contains the following
>>
>> (defun S::STARTUP()
>> (command "_-vbaload" "StoreSpace.dvb")
>> (command "_-VBARUN" "Initialise")
>> )
>>
>> and acaddoc.lsp which contains the following:-
>> (defun S::STARTUP()
>> (command "_-VBARUN" "Runsynchronise")
>> )
>>
>
> Your "S::STARTUP" function in "acaddoc.lsp" is overwriting
> the same function as defined in "acad.lsp"
>
> "Acad.lsp" loads first, defining S::STARTUP.
> Then "acaddoc.lsp" loads, redefining S::STARTUP.
>
> Put all your startup code in a function called "mystartup",
> (in "acaddoc.lsp") and append it to S::Startup, in case it's
> already defined somewhere else...
>
> (defun-q mystartup ()
> (this is my startup code)
> )
> (setq S::STARTUP (append S::STARTUP mystartup))
>
>
>
>
>
>
>

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

Post to forums  

Autodesk Design & Make Report

”Boost