Results 1 to 5 of 5

Thread: Lisp not recognizing last entity... I think?

  1. #1
    Member
    Join Date
    2008-05
    Posts
    25
    Login to Give a bone
    0

    Default Lisp not recognizing last entity... I think?

    Below is part of a lisp I have for inserting a titleblock. I will attach this file as well, so it is available for testing. I have this lisp working perfectly w/ another titleblock and this is a direct Save As of the previous lisp and titleblock. Now I am getting an error. The best I can tell, when the (If (= el (entlast)) line runs, it is coming up as =, and it shouldn't be at that point. Can someone check this thing out and help me? Any other info you need, etc. just let me know and I will get it for you ASAP.

    I have 8 different titleblocks I need to modify this Lisp for, so I want to get it RIGHT this time instead of having to mess w/ it 8 different times.

    Thanks in advance!
    Steven

    Code:
    ;	ProESubm_FabB.lsp
    ;;;--------------------------------------------------------------------
    ;;;		M A I N   F U N C T I O N
    ;;;--------------------------------------------------------------------
    
    (princ "\nProESubm_FabB Insert")
    (Defun C:ProESubm_FabB (/	OSN   LA    n0	  n1	n2    thei
    			  tlen	A0    A1    A2	  A3	A00   ws
    			  xscl	yscl  dwgscl	  rtio	scls  R0
    			  R1	P0    P1    P2	  P3	shtscl
    			  tx	txlist	    pmt1  edf	u     uprec
    			  	
    			 )
    
      (Command "Undo" "Mark")
      (Setvar "Cmdecho" 1)
      (Setvar "Limcheck" 0)
      (Setvar "Blipmode" 1)
      (Setq
        OSN	  (Getvar "Osmode")
        u	  (Getvar "Lunits")		;Save Unit type
        uprec (Getvar "Luprec")		;Save Unit precision
        LA	  (Getvar "CLAYER")		;Save current layer
      )
      (Setvar "Osmode" 0)
      (Setvar "Lunits" 2)
      (Setvar "Luprec" 8)
      (Setvar "Plinewid" 0)
    
    ;;;--------------------------------------------------------
    ;;;	Set Coordinates for Working on Title Block
    ;;;--------------------------------------------------------
    
      (Setq
        n0	 (list 0.0 0.0)			;Lower Left Node
        n1	 (list 0.07000000 0.90000000)	;Lower Left Bdr Pt
        n2	 (list 16.25000000 10.20000000)	;Upper Right Bdr Pt
        A0	 (/ (- (Car n2) (Car n1)) 2)	;Half of drawing width
        A1	 (/ (- (Cadr n2) (Cadr n1)) 2)	;Half of drawing height
        A00	 (list (+ (Car n1) A0) (+ (Cadr n1) A1)) ;Center of Dwg Space
      )
    
    
    ;;;  -----------------------------------------------------
    ;;;  	Fill in title block info
    ;;;  -----------------------------------------------------
      
      (Setq
          Proc (getstring T "\nEnter Process: ")
          Desc1 (getstring T "\nEnter Description Line 1: ")
          Desc2 (getstring T "\nEnter Description Line 2: ")
          DrwBy (getstring T "\nEnter Drawn By: ")
          ChkBy (getstring T "\nEnter Checked By: ")
          DwgNo (getstring T "\nEnter Drawing Number: ")
          ShtNo (getstring T "\nEnter Sheet Number: ")
          TotSht (getstring T "\nEnter Total Number of Sheets: ")
          Rev (getstring T "\nEnter Revision: ")
          RevDesc (getstring T "\nEnter Revision Description: ")
          Date (getstring T "\nEnter Date: ")
      )
    
    ;;;--------------------------------------------------------
    ;;;	Window Extents, Calculate Scale,
    ;;;	and Move to Center of Dwg Space
    ;;;--------------------------------------------------------
    
      (Command "Zoom" "Extents")
      (Setq
        P2	 (Getvar "EXTMAX")
        P1	 (Getvar "EXTMIN")
        thei (- (Cadr P2) (Cadr P1))
        tlen (- (Car P2) (Car P1))
        A2	 (/ thei 2)
        A3	 (/ tlen 2)
        P0	 (List (+ (Car P1) A3)
    	       (+ (Cadr P1) A2)
    	 )
      )
    
    ;;;---------------------------------------------------------------------
    ;;;		Calculate "xscl" - Drawing Scale Required Horizontally
    ;;;---------------------------------------------------------------------
    
      (Setq xscl (/ tlen (* A0 2)))		;used A0 to control width instead of constant
    
    ;;;---------------------------------------------------------------------
    ;;;		Calculate "yscl" - Drawing Scale Required Vertically
    ;;;---------------------------------------------------------------------
    
      (Setq yscl (/ thei (* A1 2)))		;used A1 to control width instead of constant
    
    ;;;---------------------------------------------------------------------
    ;;;		Set "dwgscl" - Overall Drawing Scale
    ;;;---------------------------------------------------------------------
    
      (If (>= xscl yscl)
        (Setq dwgscl xscl)
        (Setq dwgscl yscl)
      )
      (Setq
        scls (List 0.25 0.5 1 2 3 4 5 5.3333 6 8
    	       10 12 16 20 24 30 32 40 48 50 56 60
    	       64 72 96 100 120 128 144 160 200 240 296 320 360 400 480
    	       560 600 640 720 960 1200 1280 1400 1920 2400 3840
    	)
        R0	 0
        R1	 (length scls)
      )
      (While (< R0 R1)
        (If	(And
    	  (< (nth R0 scls) dwgscl)
    	  (>= (nth (1+ R0) scls) dwgscl)
    	)
          (progn
    	(Setq
    	  dwgscl (nth (1+ R0) scls)
    	  R0	 R1
    	)
          )
          (progn
    	(Setq R0 (1+ R0))
    	(If (= R0 R1)
    	  (Setq dwgscl (nth R0 scls))
    	)
          )
        )
      )
    
    
    ;;;---------------------------------------------------------------------
    ;;;		Calculate the Center of New Dwg Space
    ;;;		and Move Contents to that Center
    ;;;---------------------------------------------------------------------
    
      (Setq edf (rtos dwgscl 2 4))		;set edf = dwgscl to 4 decimal places
    
      (While (/= edf nil)
        (Setq
          A4 (* (- (Car n1) (Car n0)) dwgscl)
          A5 (* (- (Cadr n1) (Cadr n0)) dwgscl)
          n1 (List (+ (Car n0) A4) (+ (Cadr n0) A5))
          A6 (* (- (Car A00) (Car n0)) dwgscl)
          A7 (* (- (Cadr A00) (Cadr n0)) dwgscl)
          P3 (List (+ (Car n0) A6) (+ (Cadr n0) A7))
          ws (* dwgscl 5)			;Window Size for Editing Title Block
        )
    
        (Command "Move" "all" "" P0 P3)
    
    
    ;;;-------------------------------------------------------
    ;;;		Place Border
    ;;;-------------------------------------------------------
    
        (Setvar "ATTDIA" 0)
        (Setvar "ATTREQ" 0)
    
        (Setvar "CLAYER" "0")
    
        (Setq el (entlast))
        (Command
          "Insert"
          (findfile
    	"N:/Engineering Data/Software/AutoCAD/AutoCAD Common/Templates/Fab-B-new.dwg"
          )
          n0
          dwgscl
          ""
          0
        )
    
        (If	(= el (entlast))
          (progn
    	(Print "No Border Placed")
    	(EXIT)
          )					;end progn
          (Setq el (entlast))
        )					;end (If (= el (entlast)
    
        (If	(Or
    	  (/= (cdr (assoc 0 (entget (entlast)))) "INSERT")
    	  (/= (cdr (assoc 2 (entget (entlast)))) "Fab-B-new.dwg")
    	)
          (progn
    	(Print "No Border Placed")
    	(EXIT)
          )
        )
    
        (Command "'Zoom" "Extents")
    
    
            )
      )
    Attached Files Attached Files

  2. #2
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Lisp not recognizing last entity... I think?

    If most of the code is going to be unchanged between all 8 versions then I strongly suggest that you revise the code so that only the data changes in a single application. For example, you would have a single routine to place all titleblocks. The user is prompted for the titleblock to use. The titleblock's unique data is stored under the titleblock's name. You can then have this single routine retrieve the data based on the user's input.

    Code:
    (setq tbData 
     (list
      (cons "Titleblock A" (list 8.5 11.0))
      (cons "Titleblock B" (list 17.0 11.0))
      (cond "Titleblock C" (list 22.0 17.0))))
    
    (setq inpTBlk "Titleblock A")
    (setq x (nth 0 (cdr (assoc inpTBlk tbData))))
    (setq y (nth 1 (cdr (assoc inpTBlk tbData))))
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  3. #3
    Member
    Join Date
    2008-05
    Posts
    25
    Login to Give a bone
    0

    Default Re: Lisp not recognizing last entity... I think?

    Quote Originally Posted by RobertB View Post
    If most of the code is going to be unchanged between all 8 versions then I strongly suggest that you revise the code so that only the data changes in a single application. For example, you would have a single routine to place all titleblocks. The user is prompted for the titleblock to use. The titleblock's unique data is stored under the titleblock's name. You can then have this single routine retrieve the data based on the user's input.
    That's a great idea Robert, and I will hopefully get to that point. I need to look through the codes and find out what all will vary, and see if I can figure out how to call the necessary info. I don't think that will be too tough. I still don't understand why I am getting the errors that I am though. I worry that combining the lisps will only make this more difficult to trouble shoot.

    Here is the part of the script that is giving me the error. I wasn't the first el = entlast like I thought. I don't know which element (is that the right term?) this is comparing.

    Code:
    (If	(Or
    	  (/= (cdr (assoc 0 (entget (entlast)))) "INSERT")
    	  (/= (cdr (assoc 2 (entget (entlast)))) "Fab-B-new.dwg")
    	)
          (progn
    	(Princ "\nOther Problem. No Border Placed")
    	(EXIT)
          )
        )
    Last edited by stevenw00; 2009-08-06 at 01:33 PM. Reason: Updated info in post.

  4. #4
    Member
    Join Date
    2008-05
    Posts
    25
    Login to Give a bone
    0

    Default Re: Lisp not recognizing last entity... I think?

    Update... I figured it out. In the section in question it was asking for the block name, and I had entered the file name. Problem is fixed now.

    Robert, I'll look into consolidating everything like you mentioned.
    Thanks.

  5. #5
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Lisp not recognizing last entity... I think?

    Quote Originally Posted by stevenw00 View Post
    Update... I figured it out. In the section in question it was asking for the block name, and I had entered the file name. Problem is fixed now.

    Robert, I'll look into consolidating everything like you mentioned.
    Thanks.
    I think you prefer that in the long run.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

Similar Threads

  1. Break an entity by LISP
    By hyd2007 in forum AutoLISP
    Replies: 1
    Last Post: 2008-09-03, 06:09 AM
  2. Replies: 5
    Last Post: 2007-04-30, 08:14 PM
  3. Proxy Entity Code 310 to Normal Entity
    By KevinBarnett in forum AutoCAD General
    Replies: 2
    Last Post: 2005-05-26, 07:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •