Author Topic: Acad protected symbol?  (Read 3638 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Acad protected symbol?
« on: January 04, 2010, 07:21:02 PM »
'acad' just appeared blue in VLIDE - its listed as a SUBR, so maybe I'm missing something, but what does it do?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Acad protected symbol?
« Reply #1 on: January 04, 2010, 07:55:02 PM »
One way is ;

The function c:ACAD has been compiled  ( creating a type SUBR )

and the definition has been protected.

ie In the VLIDE
Compile this as .FAS
Code: [Select]
(pragma '((unprotect-assign c:acad)))

(Defun c:acad () (alert "This is the ACAD function for SUBR")(princ))

(pragma '((protect-assign c:Acad)))

Load the FAS, Then try
(type c:acad)
and
'ACAD' at the command line

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Acad protected symbol?
« Reply #2 on: January 04, 2010, 07:59:20 PM »

So, short answer ..
'Someone' has defined c:ACAD in a FAS or VLX with a protected Assignment.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Acad protected symbol?
« Reply #3 on: January 05, 2010, 01:32:56 AM »

Coming back for a revisit and a wild-assed guess.

if you evaluate the function does it return the IAcadApplication Object
ie ; something similar to the return from (vlax-get-acad-object)


for interest, is it a command or a function  ie c:Acad or (acad)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Acad protected symbol?
« Reply #4 on: January 05, 2010, 09:31:38 AM »
Sorry for the late response Kerry -

My guess is it was your first suggestion - as, after I restarted ACAD, (type acad) returned nil, and it no longer showed up as blue in the VLIDE.

But I shall look out for it in the future, and keep this thread noted  ;-)

Thanks for your time sir.

Lee

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Acad protected symbol?
« Reply #5 on: January 05, 2010, 10:47:30 AM »

my pleasure and no problem.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CHulse

  • Swamp Rat
  • Posts: 504
Re: Acad protected symbol?
« Reply #6 on: January 05, 2010, 08:29:36 PM »
So maybe this is a similar issue?

no idea where to begin to look to fix this... help?
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Acad protected symbol?
« Reply #7 on: January 05, 2010, 08:34:42 PM »


Yep,
Simply means that c:AI_MOLC is defined as a protected Symbol and you are redefining it.
Simply select No if you want to continue ... otherwise autoLisp spits the dummy.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Acad protected symbol?
« Reply #8 on: January 05, 2010, 09:42:40 PM »
It's here in ACAD2000.
Code: [Select]
Command: (type c:acad)
nil

Command: (type acad)
SUBR
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Acad protected symbol?
« Reply #9 on: January 05, 2010, 09:48:51 PM »

Alan
what is the result of (acad) ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Acad protected symbol?
« Reply #10 on: January 05, 2010, 09:58:08 PM »
Nothing apparent!
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Acad protected symbol?
« Reply #11 on: January 05, 2010, 10:01:11 PM »
I just did a search of some archive drives
found this from some 2004 snippets

;;//----------------------------------------------------------------
;|
> (defun acad  ()
>  (vlax-Get-Acad-Object)
> )
|;

so that came from an AutoDesk Newsgroup posting.

and I have some notes added regarding not liking it because
each call to (vlax-get-acad-object) increments the reference count of the Application object.
To destroy the reference we must call (vlax-release-object) the exact same number of times that
(vlax-get-acad-object) was called.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Acad protected symbol?
« Reply #12 on: January 06, 2010, 06:38:23 AM »
I just did a search of some archive drives
found this from some 2004 snippets

;;//----------------------------------------------------------------
;|
> (defun acad  ()
>  (vlax-Get-Acad-Object)
> )
|;

so that came from an AutoDesk Newsgroup posting.

and I have some notes added regarding not liking it because
each call to (vlax-get-acad-object) increments the reference count of the Application object.
To destroy the reference we must call (vlax-release-object) the exact same number of times that
(vlax-get-acad-object) was called.


Well that explains a lot - thanks for the digging Kerry.

So, with that information, when I call vlax-get-acad-object in my code, should I also be releasing it, as I would with something like vla-getInterfaceObject?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Acad protected symbol?
« Reply #13 on: January 06, 2010, 07:21:53 AM »
Well that explains a lot - thanks for the digging Kerry.

So, with that information, when I call vlax-get-acad-object in my code, should I also be releasing it, as I would with something like vla-getInterfaceObject?

I'll have to say it depends who you talk to ( and what sort of mood that person/authority is in when you ask).

In my production code I declare and assign those variables once in each document namespace by using unique global variables ;
however, I've given up being concerned about other peoples code because I can't point to a definitive reference outlining what should and shouldn't be done.

There may be some discussions on the matter here.
yep ... here's a couple. http://www.theswamp.org/index.php?topic=7496.0  http://www.theswamp.org/index.php?topic=2005.0
  and each of those references several other threads  ...  like I said, not a demonstrable issue.

<edit: fixed the URL>
« Last Edit: January 06, 2010, 10:36:52 AM by CAB »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Acad protected symbol?
« Reply #14 on: January 06, 2010, 10:56:44 AM »
Wow! Thanks Kerry - that's a lot of info to dig through!

From the general gist of things though, it seems to me that most are of the opinion that you need to vlax-release those objects created by vla-getInterface.. vlax-get-or-create... vlax-create, but vlax-get-acad-object will take care of itself, as its from within AutoCAD.

But, as you say, I suppose it depends who you talk to...

Thanks for your time,

Lee