AutoLISP Error - Trying to determine if there is a conflict from 2018 to 2020 update?

AutoLISP Error - Trying to determine if there is a conflict from 2018 to 2020 update?

BolstadDDesignServ_LLC
Explorer Explorer
395 Views
4 Replies
Message 1 of 5

AutoLISP Error - Trying to determine if there is a conflict from 2018 to 2020 update?

BolstadDDesignServ_LLC
Explorer
Explorer

Good Morning, I having an issue running a LISP that was created prior to a AutoCAD 2020 update., as I was running it on our 2018 software. But currently we are experiencing an error with the LISP program.  We run as master LISP command that runs several LISP commands (6 to be exact) at once.  These are run within a template we have created. Can anyone give me some advice on how to find the specific problem?

 

Thanks, Jason

0 Likes
396 Views
4 Replies
Replies (4)
Message 2 of 5

BolstadDDesignServ_LLC
Explorer
Explorer

Here is our Master LISP command;

 

(defun c:s1 ( / ss1 e1)

;;Transfers elements from layer bgspa_floor_area_b to A-FLOR-FTPT
;;Transfers elements from layer bgspa_space_area_b to A-FLOR-PERI
;;Transfers elements from layer bgspa_space_area_c to A-AREA-IDEN
;;Changes text to color white By Layer
;;Places a line spacing value of 1 between Multiline Text
;;Zoom Extents the building to fill the screen

 

(defun ECHG (ent fld val)
(setq ent (subst (cons fld val) (assoc fld ent) ent))
(entmod ent)
)
(command "zoom" "e")

(setq ss1 (ssget "X" (list (cons 8 "bgspa_space_area_b"))))
(command "chprop" ss1 "" "la" "A-FLOR-PERI" "c" "bylayer" "")

(setq ss1 (ssget "X" (list (cons 8 "bgspa_floor_area_b"))))
(command "chprop" ss1 "" "la" "A-FLOR-FTPT" "c" "bylayer" "")

(setq ss1 (ssget "X" (list (cons 8 "bgspa_space_area_c"))))
(command "chprop" ss1 "" "la" "A-AREA-IDEN" "c" "bylayer" "")

(setq ss1 (ssget "X" (list (cons 0 "MTEXT")(cons 8 "A-AREA-IDEN"))))

(command "_.justifytext" ss1 "" "_MC")


(setq C 0)
(progn
(repeat (sslength ss1)
(setq e1 (entget (ssname ss1 C)))
(setq e1 (echg e1 40 12))
(setq e1 (echg e1 44 0.9))
(setq e1 (echg e1 7 "Arial"))
(setq e1 (echg e1 1 (vl-string-subst "sf" "sq ft" (cdr (assoc 1 e1)))))
(setq C (+ C 1))
)
)

 

(command "_.textstyle" "Arial")
)

(defun c:Slab ( / ss1 e1)

;;This changes the text style of A-ANNO-TEXT which is the sheet label text to arial with a middle left justification


(defun ECHG (ent fld val)
(setq ent (subst (cons fld val) (assoc fld ent) ent))
(entmod ent)
)

(setq ss1 (ssget "X" (list (cons 0 "MTEXT")(cons 8 "A-ANNO-TEXT"))))

(command "_.justifytext" ss1 "" "_ML")


(setq C 0)
(progn
(repeat (sslength ss1)
(setq e1 (entget (ssname ss1 C)))
(setq e1 (echg e1 40 12))
(setq e1 (echg e1 44 0.9))
(setq e1 (echg e1 7 "Arial"))
(setq C (+ C 1))
)
)


(command "_.textstyle" "Arial")

)

(defun c:DimUPD (/ *error* ocm lays ss)


;;This is used when the template file contains the dim style PRISMS_AEC CAD Standard, it updates properties to Bylayer.
;;Used to set UCS based on an object, in this case we will use the sheet label
;;this also updates all dimensions to the current UCS, once dimensions are set to current UCS, reset UCS back to view

 

 


(defun *error* (msg)
(if ocm (setvar "CMDECHO" ocm))
(if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
(princ (strcat "\n<< Error: " msg " >>")))
(princ))

(setq ocm (getvar "CMDECHO")
lays (vla-get-layers
(vla-get-ActiveDocument
(vlax-get-acad-object))))
(setvar "CMDECHO" 0)
(or (tblsearch "LAYER" "A-ANNO-DIMS")
(vla-put-color
(vla-add lays "A-ANNO-DIMS") 2))
(if (and (tblsearch "DIMSTYLE" "PRISMS_AEC CAD Standard")
;(if (and (tblsearch "DIMSTYLE" "AEC CAD Standard R5")
(setq ss (ssget "_X" '((0 . "LEADER,DIMENSION")))))
(progn
;(command "-dimstyle" "_R" "AEC CAD Standard R5")
(command "-dimstyle" "_R" "PRISMS_AEC CAD Standard")
(command "_.chprop" ss "" "_LA" "A-ANNO-DIMS" "")
(command "_.chprop" ss "" "C" "BYLAYER" "")
(command "-dimstyle" "_A" ss ""))

(princ "\n<< No Dimensions Found, or Dimstyle Doesn't Exist >>"))
(setvar "CMDECHO" ocm)

(command "_.ucs" "_OB" PAUSE)

;; removed, auto-select(prompt "\nSelect dimensions to set to current UCS: ")
(if (and (setq ss (ssget "_X" '((0 . "DIMENSION"))))
(> (setq n (sslength ss)) 0)
) ;_ end of and

(repeat n
(setq en (ssname ss (setq n (1- n))) ;Get the nth entity and decrement the counter
ed (entget en) ;Get the DXF data
) ;_ end of setq
(setq ucs (- 0 (angle '(0.0 0.0 0.0) (getvar "UCSXDIR")))) ;Get the current UCS's X-axis direction
(setq ed (subst (cons 51 ucs) (assoc 51 ed) ed)) ;Modify the data
(entmod ed) ;Modify the entity
) ;_ end of repeat
) ;_ end of if

(command "ucs" "previous")

(princ)
)

(DEFUN C:STT()
;;DEFINE A FUNCTION NAMED "STT"
(SETQ TARGENT (CAR (ENTSEL "\NSELECT OBJECT ON LAYRER TO SELECT: ")))
;;PROMPT USER TO SELECT OBJECT, ENTSEL STORESPICK PINT & ENTITY NAME
(SETQ TARGLAYER (ASSOC 8 (ENTGET TARGENT)))
;;EXTRACT LAYER NAME OF ENTITY USING "ENTGET" TO RETRIEVE ENTITY DATA
;; 'ASSOC' TO EXTRACT PORTION OF DATA PAIR, '8' IS THE LAYER NAME GROUP CODE

(SSSETFIRST NIL (SSGET "_X" (LIST TARGLAYER)))

;;SSGET USED TO SELECT ALL ITEMS (THE 'X' OPTION) HAVING SAME LAYER NAME
;;SSSETFIRST USED TO GRIP & HIGHLIGHT ITEMS

)

(defun c:acrun (/)
(c:s1)
(c:slab)
(c:dimupd)
(c:stt)
(command "move")
)

 

ERROR  DURING PROCESSING...

INSERT .DWG into AutoCAD Session with TEMPLATE loaded.

 

Command: I

INSERT

Command: Duplicate definition of block _Oblique  ignored.

Duplicate definition of block NORTH  ignored.

Duplicate definition of block NorthArrow2  ignored.

Substituting [simplex.shx] for [WORKING.shx].

Substituting [simplex.shx] for [STANDARD.shx].

Substituting [ROMANTIC.TTF] for [ROM_____.PFB].

Substituting [simplex.shx] for [WORKING.shx].

Substituting [simplex.shx] for [WORKING.shx].

Command:

Command: *Cancel*

Command: *Cancel*

Command:

Command: AC

BACTION ** BACTION command only allowed in Block Editor. **

Command: ACRUN

zoom

Specify corner of window, enter a scale factor (nX or nXP), or

[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: e Regenerating model.

Command: chprop

Select objects:

Command: ACRUN

Unknown command "ACRUN".  Press F1 for help.

Command: la Unknown command "LA".  Press F1 for help.

Command: A-FLOR-PERI Unknown command "A-FLOR-PERI".  Press F1 for help.

Command: c Unknown command "C".  Press F1 for help.

Command: bylayer Unknown command "BYLAYER".  Press F1 for help.

Command: ACRUN

Unknown command "ACRUN".  Press F1 for help.

Command: chprop

Select objects:

Command: ACRUN

Unknown command "ACRUN".  Press F1 for help.

Command: la Unknown command "LA".  Press F1 for help.

Command: A-FLOR-FTPT Unknown command "A-FLOR-FTPT".  Press F1 for help.

Command: c Unknown command "C".  Press F1 for help.

Command: bylayer Unknown command "BYLAYER".  Press F1 for help.

Command: ACRUN

Unknown command "ACRUN".  Press F1 for help.

Command: chprop

Select objects:

Command: ACRUN

Unknown command "ACRUN".  Press F1 for help.

Command: la Unknown command "LA".  Press F1 for help.

Command: A-AREA-IDEN Unknown command "A-AREA-IDEN".  Press F1 for help.

Command: c Unknown command "C".  Press F1 for help.

Command: bylayer Unknown command "BYLAYER".  Press F1 for help.

Command: ACRUN

Unknown command "ACRUN".  Press F1 for help.

Command: _.justifytext

Select objects:

Command: ACRUN

Unknown command "ACRUN".  Press F1 for help.

Command: _MC Unknown command "MC".  Press F1 for help.

 

 

 

0 Likes
Message 3 of 5

pbejse
Mentor
Mentor

@BolstadDDesignServ_LLC wrote:

Here is our Master LISP command;

Command: ACRUN

zoom

Specify corner of window, enter a scale factor (nX or nXP), or

[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: e Regenerating model.

Command: chprop

Select objects:

...

Command: ACRUN

Unknown command "ACRUN".  Press F1 for help.

Command: la Unknown command "LA".  Press F1 for help.

Command: A-FLOR-PERI Unknown command "A-FLOR-PERI".  Press F1 for help.

Command: c Unknown command "C".  Press F1 for help.

Based on that error, variable ss1 evaluated to nil and the line below continued to process ss1

(command "chprop" ss1 "" "la" "A-FLOR-PERI" "c" "bylayer" "")

and that extra enter "" [ Return/Enter ] after ss1 caused this error

Unknown command "ACRUN".  Press F1 for help.

and continued to call "LA"

Command: la Unknown command "LA".  Press F1 for help.

What you should do is the evalaute the selection (ss1) before invoking the command similar to what you had on c:DimUPD function

(defun c:s1 (/ ss1 e1)

  ;;Transfers elements from layer bgspa_floor_area_b to A-FLOR-FTPT
  ;;Transfers elements from layer bgspa_space_area_b to A-FLOR-PERI
  ;;Transfers elements from layer bgspa_space_area_c to A-AREA-IDEN
  ;;Changes text to color white By Layer
  ;;Places a line spacing value of 1 between Multiline Text
  ;;Zoom Extents the building to fill the screen



  (defun ECHG (ent fld val)
    (setq ent (subst (cons fld val) (assoc fld ent) ent))
    (entmod ent)
  )
  (command "zoom" "e")

  (foreach lay '(("bgspa_space_area_b" "A-FLOR-PERI")
		 ("bgspa_floor_area_b" "A-FLOR-FTPT")
		 ("bgspa_space_area_c" "A-AREA-IDEN"))
    
    (if (setq ss1 (ssget "X" (list (cons 8 (Car lay)))))
	(command "chprop" ss1	"" "la"	(Cadr lay) "c" "bylayer" "")
      )
    (princ (strcat "\nNo object(s) found on layer " (Car lay)))
    )

  (if
    (setq ss1 (ssget "X" (list (cons 0 "MTEXT") (cons 8 "A-AREA-IDEN")))
    )
     (progn
       (command "_.justifytext" ss1 "" "_MC")
  	(setq C 0)
	    (repeat (sslength ss1)
	      (setq e1 (entget (ssname ss1 C)))
	      (setq e1 (echg e1 40 12))
	      (setq e1 (echg e1 44 0.9))
	      (setq e1 (echg e1 7 "Arial"))
	      (setq e1 (echg e1
			     1
			     (vl-string-subst "sf" "sq ft" (cdr (assoc 1 e1)))
		       )
	      )
	      (setq C (+ C 1))
	    )
       (command "_.textstyle" "Arial")
	  )       
     (princ (strcat "\nNo Mtext(s) found on layer A-AREA-IDEN"))
  )
  (princ)
)

You should do the same for c:Slab function

 

HTH

0 Likes
Message 4 of 5

BolstadDDesignServ_LLC
Explorer
Explorer

Can you help me with the SLAB command. I still very new at AutoLISP programming. 

 

Current SLAB command function:

 

(defun c:Slab ( / ss1 e1)
;;This changes the text style of A-ANNO-TEXT which is the sheet label text to arial with a middle left justification

(defun ECHG (ent fld val)
(setq ent (subst (cons fld val) (assoc fld ent) ent))
(entmod ent)
); end of internal defun

(setq ss1 (ssget "X" (list (cons 0 "MTEXT")(cons 8 "A-ANNO-TEXT"))))

(if ss1 (command "_.justifytext" ss1 "" "_ML"))


(setq C 0)
(if ss1
(progn
(repeat (sslength ss1)
(setq e1 (entget (ssname ss1 C)))
(setq e1 (echg e1 40 12))
(setq e1 (echg e1 44 0.9))
(setq e1 (echg e1 7 "Arial"))
(setq C (+ C 1))
)
); end of progn
)

(command "_.textstyle" "Arial")

)

 

 

0 Likes
Message 5 of 5

pbejse
Mentor
Mentor

You did alright

(defun c:Slab (/ ss1 e1)
  ;;This changes the text style of A-ANNO-TEXT which is the sheet label text to arial with a middle left justification

  (defun ECHG (ent fld val)
    (setq ent (subst (cons fld val) (assoc fld ent) ent))
    (entmod ent)
  )					; end of internal defun

  (if
    (setq
      ss1 (ssget "X" (list (cons 0 "MTEXT") (cons 8 "A-ANNO-TEXT")))
    )
     (progn
       (command "_.justifytext" ss1 "" "_ML")
       (setq C 0)
       (repeat (sslength ss1)
	 (setq e1 (entget (ssname ss1 C)))
	 (setq e1 (echg e1 40 12))
	 (setq e1 (echg e1 44 0.9))
	 (setq e1 (echg e1 7 "Arial"))
	 (setq C (+ C 1))
       )
       (and
	 (tblsearch "style" "Arial")
	 (command "_.textstyle" "Arial")
       )
     )					; end of progn
  )					; if
  (princ)
)

HTH

0 Likes