Lisp Error

Lisp Error

thomas_huntFMPXR
Contributor Contributor
245 Views
5 Replies
Message 1 of 6

Lisp Error

thomas_huntFMPXR
Contributor
Contributor

What are these errors after uploaded the lisp command in appload?

0 Likes
246 Views
5 Replies
Replies (5)
Message 2 of 6

pkenewell6347
Advocate
Advocate

1) The first one is a Syntax error. There is an extra closing parenthesis in a LISP statement somewhere. The file won't load until this is found and fixed.

 

2) Automation Error: Key not found. "The program is attempting to use the Item method of a VLA Collection Object to access an item not present in that collection."

 

Here is a link that might help with error troubleshooting:

https://www.lee-mac.com/errormessages.html

0 Likes
Message 3 of 6

paullimapa
Mentor
Mentor

Could you share the lisp assuming it’s open source?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 6

thomas_huntFMPXR
Contributor
Contributor

defun c:ldr (/)

;set variables
(setq LL (getvar "clayer") CC (getvar "dimasz") DD (getvar "dimtxt") DIM (getvar "dimstyle") color (getvar "cecolor")
ML (getvar "cmleaderstyle"))

;check for fire setbacks and trench
(command "_mspace")
(setq h (/ (getvar 'viewsize) 2.0)
a (apply '/ (getvar 'screensize))
v (list (* h a) h)
c (trans (getvar 'viewctr) 1 0)
)
(setq pt1 (mapcar '- c v) pt2 (mapcar '+ c v))
(setq ssFire (ssget "w" pt1 pt2 '(("Setbacks"))))
(command "_._Mspace")

;setup
(command "cecolor" "ByLayer")
(command "dimstyle" "PV-TEXT-NOTE" "mspace")
(setvar "cmleaderstyle" "mspace")
(setvar "dimasz" 1'=10')
(setvar "dimasz" 1'=15')
(setvar "dimasz" 1'=20')
(setvar "dimtxt" 1-8")
(setvar "clayer" "Anno")

;setbacks
(if (/= ssnil) (progn
(setq pt (getpoint "\nSETBACKS"))
(command "mleader" pt pause "SETBACKS(#'TYP)")
)) ;if

;equipment pad 1
(if (= (strcase ct) "MODEL") (progn ;if Model page
(setq pt (getpoint "\nEQUIPMENT\PAD1"))
(command "mleader" pt pause "nEQUIPMENT\PAD1")

;equipment pad 1
(if (= (strcase ct) "MODEL") (progn ;if Model page
(setq pt (getpoint "\nEQUIPMENT\PAD2"))
(command "mleader" pt pause "\nEQUIPMENT\PAD2")

;trench
(if (/= ssTrench nil) (progn
(setq pt (getpoint "\nTRENCH"))
(command "mleader" pt pause "(N) n(ENTRENCHED ~ # FT)")

;(e)structure
(setq pt (getpoint "\nSTRUCTURE"))
(command "mleader" pt pause "(E) \nSTRUCTURE")
)) ;if

;street
(setq pt (getpoint "\nSTREET1"))
(command "text" "style" "PV-TEXT-NOTE" pt 1-8" pause Street1 ")

;street 2
(setq pt (getpoint "\nSTREET2"))
(command "text" "style" "PV-TEXT-NOTE" pt 1-8" pause Street2 "")

;utility recloser pole
(setq pt (getpoint "\nUTILITY RECLOSER POLE"))
(command "mleader" pt pause "(N) n\UTILITY RECLOSER POLE")

;customer own goab
(setq pt (getpoint "\nCUSTOMER CUSTOMER GOAB"))
(command "mleader" pt pause "(N) n\CUSTOMER CUSTOMER GOAB")

;primary utility metering
(setq pt (getpoint "\nPRIMARY UTILITY METERING"))
(command "mleader" pt pause "(E) n\PRIMARY UTILITY METERING")

;property line
(setq pt (getpoint "\nPROPERTY LINE"))
(command "mleader" pt pause " n\PROPERTY LINE")

;site fence, type
(setq pt (getpoint "\nSITE FENCE, TYP"))
(command "mleader" pt pause " n\SITE FENCE, TYP")

;20' gravel access road
(setq pt (getpoint "\n20' GRAVEL ACCESS ROAD"))
(command "mleader" pt pause " n\20' GRAVEL ACCESS ROAD")

;site access gate
(setq pt (getpoint "\nSITE ACCESS GATE"))
(command "mleader" pt pause " n\SITE ACCESS GATE")

;mv trenching, typ
(setq pt (getpoint "\nMV TRENCHING, TYP"))
(command "mleader" pt pause " n\MV TRENCHING, TYP")

;tracker motor, typ
(setq pt (getpoint "\nTRACKER MOTOR, TYP"))
(command "mleader" pt pause " n\TRACKER MOTOR, TYP")

;site meter location
(setq pt (getpoint "\nSITE METER LOCATION"))
(command "mleader" pt pause " n\SITE METER LOCATION")

;restore settings
(command "dimstyle" "restore" DIM)
(setvar "cmleaderstyle" ML)
(setvar "dimasz" CC)
(setvar "dimtxt" DD)
(setvar "clayer" LL)
(command "cecolor" color)

)

0 Likes
Message 5 of 6

paullimapa
Mentor
Mentor

You should really use a lisp code app like VS Code & installed with Lisp extensions as recommended by Autodesk:

https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-7BE00235-5D40-4789-9E34-D57685E83875

This really helps you troubleshoot code like the one you posted.

First of all you cannot start a defun function with a missing open parenthesis:

defun c:ldr (/)

In addition to adding the open parenthesis you should also localize your variables:

(defun c:ldr 
; localize variables
(/ LL CC DD DIM color ML h a v c pt)

All the commands that invoke going to MSPACE would fail if you're in a Layout that has no Paperspace Vports:

(command "_mspace")

Since there's no such thing as "Setbacks" what exactly are you trying to select with this line of code:

(setq ssFire (ssget "w" pt1 pt2 '(("Setbacks"))))

What does this line of code do:

(command "dimstyle" "PV-TEXT-NOTE" "mspace")

When you enter the command at the command prompt this is what you need to answer:

paullimapa_0-1748900407299.png

This line of code would fail if there isn't an MLeader Style called "mspace":

(setvar "cmleaderstyle" "mspace")

What's the purpose of the following multiple dimasz settings & dimtxt settings when none of these work:

(setvar "dimasz" 1'=10')
(setvar "dimasz" 1'=15')
(setvar "dimasz" 1'=20')
(setvar "dimtxt" 1-8")

If 1-8" represents 1/8" which is = 0.125 then you should enter like this:

(setvar"dimtxt" 0.125)

At the command prompt when you enter those system variables you'll see the response expected:

paullimapa_1-1748900658996.png

The following line of code will fail if layer "Anno" does not exist:

(setvar "clayer" "Anno")

The following lines of code properly starts both if & progn functions with an open parenthesis but are missing matching closing parenthesis to the if & progn functions:

;equipment pad 1
(if (= (strcase ct) "MODEL") (progn ;if Model page
(setq pt (getpoint "\nEQUIPMENT\PAD1"))
(command "mleader" pt pause "nEQUIPMENT\PAD1")

;equipment pad 1
(if (= (strcase ct) "MODEL") (progn ;if Model page
(setq pt (getpoint "\nEQUIPMENT\PAD2"))
(command "mleader" pt pause "\nEQUIPMENT\PAD2")

Also what is variable ct? This is not defined anywhere in your code so you'll end up with this error:

paullimapa_3-1748901145729.png

The following lines of code refers to a variable called ssTrench which again is not defined anywhere in your code:

;trench
(if (/= ssTrench nil) (progn
(setq pt (getpoint "\nTRENCH"))
(command "mleader" pt pause "(N) n(ENTRENCHED ~ # FT)")

;(e)structure
(setq pt (getpoint "\nSTRUCTURE"))
(command "mleader" pt pause "(E) \nSTRUCTURE")
)) ;if

Since it's nil then everything in between the progn function will not be executed:

paullimapa_4-1748901280620.png

All the lines that calls for Text Style "PV-TEXT-NOTE" will fail if that Style does not exist:

(command "text" "style" "PV-TEXT-NOTE" pt 1-8" pause Street1 ")

Also notice the missing quote in front of 1-8", the missing quotes surround text Street1 and additional quote before the closing parenthesis:

If 1-8" represents 1/8" then you should enter like this:

(command "text" "style" "PV-TEXT-NOTE" pt "1/8" pause "Street1")

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 6

thomas_huntFMPXR
Contributor
Contributor

Thank you for the input. the Main function for this Lisp is to activated in model space  the leader command and list certain objects with. On Paper space you see leader objects in in different view port sizes.

0 Likes