ghimpster Posted October 18, 2016 Share Posted October 18, 2016 Hello, I have a LISP code that was running perfect in Autocad 2012. Now I've changed to Autocad 2016 and my LISP is not working like it supposed to. What is the LISP for: I need to make data extractions for a lot of metal plates to be cut. For data extractions I need next informations: -> name (plate name): input by user -> thickness (plate thickness mm): input by user -> quantity (number of the same plates): input by user -> edgelength (this is easy for the cut company to make a price offer): it's getting the information from LISP -> area (area of the plate): it's getting the information from LISP -> weight (weight of the plate, also used for price offer): it's getting the information from LISP (formula) The informations above are extracted from "regions" in Autocad and after the LISP is getting them it pops up a block attribute and it's inserting it at the left - down edge box of the object (see LISP for position). This was working very well in Autocad 2012 and before, but in Autocad 2014+ is not working anymore. In autocad 2014+ I can write the informations I am asked for but when LISP must insert the block attribute with the informations I am getting it to write the informations myself. I can't do this since some informations need to be extracted from the formulas in the LISP file (edgelength, area, weight) I have attached some examples: First one is from Autocad 2012, where the LISP is working. 2nd one is from Autocad 2016 where the LISP is working wrong and block attribute pops up instead of inserting it with the informations. Thank you for your help. Below you can find the LISP lines and LISP file: (defun C:sheet() (vl-load-com) ;turn off the system echo\ (setvar "cmdecho" 0) ;set up a variable (setq myArea 0) (setq myPeri 0) (setq aantal 0) ;soortelijk gewicht (kg/m3) (setq sg 7850) (setq ent(entsel)) ;a text insertion point\ (setq obj (vlax-ename->vla-object (car ent))) (vla-getboundingbox obj 'minpoint 'maxpoint) (setq pt1 (vlax-safearray->list minpoint)) ;standaard plaatnaam is de naam van de tekening (if (= plNaam1 nil) (setq plNaam1 (getvar "DWGname"))) (setq len (- (strlen (getvar "DWGname")) 4)) ; naam van de tekening zonder DWG (setq noDwg (substr (getvar "DWGname") 1 len)) (if (= plnaam1 (getvar "DWGname")) (setq plNaam1 noDWG)) ;aantal platen (setq aantal (getreal "\nquantity (number of plates): ")) ;dikte (if (= dikte1 nil) (setq dikte 0)) (princ "\nthickness (") (princ dikte1) (princ "mm) :") (setq dikte2 (getreal)) (if (/= dikte2 nil) (setq dikte1 dikte2)) ;plaatnaam (princ "\nplate name (") (princ plNaam1) (princ ") :") (setq plNaam2 (getstring)) ;Nil=standaardplaatnaam=naam tekening (if (/= plNaam2 "")(setq plNaam1 plNaam2)) ;plaatnummer (if (= plNr1 nil) (setq plnr1 0)) (princ "\nplate index (") (princ plNr1) (princ ") :") (setq plNr2 (getint)) (if (/= plNr2 nil) (setq plNr1 plnr2)) ;let AutoCAD get the area of the object...cheap yet effective way out.\ ;Note: AutoCAD stores the area in the system variable "Area"\ (command "area" "Object" (car ent)) (setq myArea (getvar "Area")) (setq myPeri (getvar "Perimeter")) ;berekenen gewicht (setq gewicht(* myArea dikte1 sg)) (setq gewicht(/ gewicht 1000000000)) ;maak een layer platenlijst aan (command "-layer" "make" "sheetlist" "" ) ;print the area in the drawing\ (setq zero "") (if (< plNr1 10) (setq zero "0")) ; vermijden dat block insert blijft hangen op object snap (setq snap(getvar "osmode")) (command "osmode" "0") ;(command "Mtext" pt1 "@2000,-2000" (strcat plNaam1 "_" zero (itoa plNr1)"\nOpp: " (rtos myArea 2 0) "\n""Omtrek: " (rtos myPeri 2 0)) "Aantal: " (itoa aantal)"" (command "-insert" "discription" pt1 "1" "1" "0" (strcat plNaam1 "_" zero (itoa plNr1)) (rtos aantal 2 1) (rtos dikte1 2 1) (rtos myArea 2 2) (rtos myPeri 2 2) (rtos gewicht 2 2)) (princ "\nblock succesfully written") (command "osmode" snap) ; terug naar vorige layer (command "_layerP") ;plaatnummer teller +1 (setq plNr1 (+ plNr1 1)) ;suppress the last echo\ (princ) ;turn on the system echo\ (setvar "cmdecho" 1) ) ;end of program} Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted October 19, 2016 Share Posted October 19, 2016 I think your problem is related to the ATTDIA variable. Quote Link to comment Share on other sites More sharing options...
ghimpster Posted October 19, 2016 Author Share Posted October 19, 2016 Hi Roy_043, Thank you a lot for you time reading my post. You are right about ATTDIA variable. This solved my problem! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.