A couple more options, to accomplish same:
Modify your CUI item's macro to provide the 'if not defined load the .LSP and then call the command' (I haven't used this in years personally):
Code:
^C^C^P(if (not c:FOO) (load "foo.lsp"));FOO;^P
... Or, you could just use an Autoloader .bundle to load your components; making sure to specify a given Command XmlNode and the applicable LoadOnCommandInvocation="True" XmlAttribute and value respectively.
[Edit] - PackageContents.xml snippet:
Code:
<!--snip-->
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD*" SeriesMax="R20.0" SeriesMin="R18.2" SupportPath="./Contents/Support" />
<ComponentEntry AppDescription="FOO for AutoCAD® does BAR" AppName="FOO" LoadOnCommandInvocation="True" ModuleName="./Contents/Support/foo.lsp" PerDocument="False" >
<Commands GroupName="FOO">
<Command Local="FOO" Global="FOO" />
</Commands>
</ComponentEntry>
</Components>
<!--snip-->
Cheers