Jump to content

ApplicationPlugins - Lisp.Bundle


rcb007

Recommended Posts

I am messing around with the ApplicationPlugins Bundle Folder within the AppData Folder. I have everything working however, I am not able to run commands. I can run Alerts without a problem.

 

(defun C:TestAutoLoad ()
	(Alert "Test") 
	(Alert "Test2")
	(command "-layer" "set" "defpoints" "")
(princ))

(C:TestAutoLoad)

 

When the (command "-layer" is commented out. On Startup CAD shows the 2 Alerts in a row.

 

When the (command "-layer" is shown like above, the Alerts show multiple times, more than the normal 2 Alerts.

 

Just trying to figure the format so I can get this to work. Thank you.

Link to comment
Share on other sites

Capitalization matters

also its better to use setvar

 

(defun C:TestAutoLoad ()
  (Alert "Test")
  (Alert "Test2")
  (setvar 'clayer "Defpoints")
  (princ)
)
(C:TestAutoLoad)

 

  • Like 2
Link to comment
Share on other sites

or try this

 

(defun C:TestAutoLoad ()
  (Alert "Test") 
  (Alert "Test2")
  (setvar 'cmdecho 0)
  (command "-layer" "set" "defpoints" "")
  (setvar 'cmdecho 1)
  (princ)
)

 

Link to comment
Share on other sites

I have the bundle saved under the Appdata Folder. 

 

The XML File reads the below.

<?xml version="1.0" encoding="utf-8" ?>
<ApplicationPackage 
  SchemaVersion="1.0"
  AutodeskProduct="AutoCAD"
  ProductType="Application"
  AppVersion="1.1"
  Author="---------"
  Name="LISP"
  Description="LISP"
  Icon="./logo.ico"
  HelpFile="./Help.htm"                    
  ProductCode="{7C1EEA79-B0DD-400D-9D10-8D9DA92FD4CA}"
>
  <CompanyDetails 
    Name="---"
    Url="---"
    Email="---" 
  />  
  <RuntimeRequirements Platform="AutoCAD*" />
  <Components>
    <RuntimeRequirements SupportPath="./" />
    <ComponentEntry AppName="TestAutoLoad"
                ModuleName="./TestAutoLoad.lsp" PerDocument="True" LoadOnAutoCADStartup="True" LoadOnCommandInvocation="True" />
  </Components>
</ApplicationPackage>

 

The Routine Reads:

(defun C:TestAutoLoad ()
  (Alert "Test") 
  (Alert "Test2")
  (setvar 'cmdecho 0)
  (command "-layer" "set" "defpoints" "")
  (setvar 'cmdecho 1)
  (princ)
)
(C:TestAutoLoad)

 

When I start CAD, I do get the alerts but it does its several times. This is what the command line reads.

COMMANDLINE
Command: ; error: AutoCAD command rejected: "-layer"
; error: AutoCAD command rejected: "-layer"
; error: AutoCAD command rejected: "-layer"
; error: AutoCAD command rejected: "-layer"
; error: AutoCAD command rejected: "-layer"
Command: Regenerating model.

 

 

Thank you again for the help. It is like it does not like to use (commands).

Capture.PNG

Link to comment
Share on other sites

Wanted to share, I found a workaround. 

From Here https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/error-autocad-command-rejected/td-p/10210987

 

(defun mystartup ()
(princ "\nloaded")
;;(command "menubar" "1")
(command "-layer" "set" "defpoints" "")
(princ "\nended")
)

(if s::startup
(setq s::startup (append s::startup (quote ((mystartup)))))
(defun s::startup () (mystartup))
)
(princ)

 

 

Now when this format is used. Defpoints becomes Active.

Link to comment
Share on other sites

First Google search for Autocad defpoints layer issues returns About 166,000 results explaining why you should never use the Defpoints layer whose only purpose is for Dimension nodes. Setting your own layers to non-plotting in layer manager or with code or macro is easy enough and will not cause issues in you drawings.

 

One of those unwritten AutoCAD rules like not adding objects on layer 0 unless you're creating a block.

 

If you were going to do something crazy like that anyway why wouldn't you use the much cleaner example mhupp provided than that workaround?

Link to comment
Share on other sites

Thanks for the feedback tombu. I was using that as an example of code. I was able to get everything work.


I did notice one odd thing, when I have multiple bundles that are Lisps. When I first open CAD it loads all the bundles in normally. But when I start another dwg or open another. It errors out again with the following.

 

; error: Invalid attempt to access a compiled function definition.  You may want to define it using defun-q:

 

I did try as it suggested but  I still get the same error. 

(if s::startup
(setq s::startup (append s::startup (quote ((mystartup)))))
(defun-q s::startup () (mystartup))
)
(princ)

 

So currently, i am just using one bundle with one lisp and it works normally, including opening other files after the first one loads from starting CAD.

Link to comment
Share on other sites

If you avoid using command calls using clean lisp like mhupp's example you could use acaddoc.lsp or an mnl file instead of s::startup to avoid those issues.

Clean code executes quicker anyway. The newer command-s or vl-cmdf are cleaner and less buggy than command for newer versions like you're using.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...