Results 1 to 5 of 5

Thread: LSP editer novice needs some help.....

  1. #1
    Member
    Join Date
    2009-05
    Posts
    10
    Login to Give a bone
    0

    Default LSP editer novice needs some help.....

    Ok I am trying to make a selection window where on the left you can choose a discipline and on the right you could chose from a selection of notes having to do with that discipline. I almost have the right code but the notes list won’t show up I was hoping someone that knows the lisp code could maybe point out my errors in this lisp routine I have copied and tweaked.

    Code:
    ;  notest.lsp
    ;----------------------------------------------------------------------------
    ; notest.lsp (Insert Standard Notes)	
    ;----------------------------------------------------------------------------
    ;
    ;----------------------------------------------------------------------------
    ; Global Variables: :
    ; 	None
    ;----------------------------------------------------------------------------
    ; Global Variables: :
    ;	DCL_ID 			Dialog ID
    ;	LOOKUP_LIST 		List of Key-Blockname Pairs
    ;	PRE_FIX 		Front end of Key (ie "TYPE01")
    ;	TYPE_ITEMS		List of title block Type strings
    ;	TYPE_LIST		List of pairs of TITLE Numbers & Type strings
    ;	TYPE_NUMS 		List of title block Numbers
    ;	SCALE_ENGLISH_LIST	List of pairs of scale strings and values
    ;	SCALE_ENGLISH_NUMS 	List of scale values
    ;	SCALE_METRIC_LIST 	List of pairs of scale strings and values
    ;	SCALE_METRIC_NUMS 	List of scale values
    ;	SUF_FIX 		Back end of Key (ie "SIZE01")
    ;	TITLE_SCALE 		Scale factor to insert title block
    ;	TITLE_UNITS		Units selected by user
    ;
    ;----------------------------------------------------------------------------
    ; Internal Functions:
    ;	disable-english	Makes English Scale list inactive
    ;	disable-metric 	Makes Metric Scale list inactive
    ;	enable-english	Makes English Scale list active
    ;	enable-metric	Makes Metric Scale list active
    ;	err 		Error handler
    ;	ins-TITLE 	Inserts title block
    ;	makelist	Makes Type list box
    ;	makelist2 	Makes English Scale list box
    ;	makelist3	Makes Metric Scale list box
    ;	read-vals 	Reads dialog values
    ;	update-scale	Switches scale lists active/inactive
     
    ;----------------------------------------------------------------------------
    ; Local Variables:
    ;	BN 	Block name
    ;	ER	Saved error handler
    ;	KEY 	Key to lookup list items
    ;	OKFLAG  Used to check if user selects OK
     
    ;----------------------------------------------------------------------------
    ; Shared Subroutines:
    ; 	getval	 Returns associated data in a list
    ;	lmake    Makes or sets layer
    ;	loadlib  Loads shared lisp functions from library
    ;	resetv	 Resets system variables
    ; 	savev	 Saves system variables
    ; 	setscale Sets scale sensitive system variables
    ; 
    ;----------------------------------------------------------------------------
     
    (if (not loadlib)
       (progn
         (if (not LISP_DIR)(setq LISP_DIR ""))
         (load (strcat LISP_DIR "loadlib"))
       );end progn
    );end if
       
    (loadlib "getval")
    (loadlib "lmake")
    (loadlib "resetv")
    (loadlib "savev")
    (loadlib "setscale") ; loads (setscale-vars)
     
    (defun C:notest( / DCL_ID LOOKUP_LIST PRE_FIX TYPE_ITEMS TYPE_LIST
                     TYPE_NUMS SCALE_ENGLISH_LIST SCALE_ENGLISH_NUMS
      		 SCALE_METRIC_LIST SCALE_METRIC_NUMS
    		 SUF_FIX TITLE_SCALE TITLE_UNITS
    		 disable-english disable-metric	enable-english
    		 enable-metric err ins-TITLE makelist
    		 makelist2 makelist3 read-vals update-scale
    		 BN ER KEY OKFLAG )
     
    ;-----edit type list - these are the names that will appear in the Type list box
     (setq TYPE_LIST 
       (list
          (cons "TYPE01" "Mechanical")
          (cons "TYPE02" "Plumbing")
         
       )
     );end setq TYPE_LIST
     
       (setq SIZE_LIST 
       (list
         (cons "SIZE01" "notes-mech")
         (cons "SIZE02" "notes-seismic")
       )
     );end setq SIZE_LIST
     
    ;-----to add/edit sizes - edit notest.dcl
     
    ;-----edit lookup list - for each line list the type#-size# then the name of 
    ;                        the block to insert. Replace TITLENAME with the name
    ;			 of each of your blocks
     (setq LOOKUP_LIST
       (list
          (cons "TYPE01-SIZE01" "notes-mech")
          (cons "TYPE01-SIZE02" "notes-seismic")
          (cons "TYPE01-SIZE03" "notes-seismic-DSA")
          (cons "TYPE01-SIZE04" "NOTES-planchk HVAC")
          (cons "TYPE01-SIZE05" "NOTES-T24")
          (cons "TYPE01-SIZE06" "NOTES-fire protect")
          (cons "TYPE01-SIZE07" "TSTAT HEIGHT")
          (cons "TYPE01-SIZE08" "LEG-HVAC DEC")
          (cons "TYPE01-SIZE09" "Design Criteria")
          (cons "TYPE01-SIZE10" "DecLogo")
          (cons "TYPE01-SIZE11" "Sheet notes")      
          (cons "TYPE01-SIZE12" "Sht-Title")
     
          (cons "TYPE02-SIZE13" "NOTES-plumb1")
          (cons "TYPE02-SIZE14" "notes-seismic")
          (cons "TYPE02-SIZE15" "NOTES-planchk plumb")
     
       );end list
     );end setq LOOKUP_LIST
     
    (defun makelist()
       (start_list "type_sel")          
       (setq TYPE_NUMS  ;get each type number
         (mapcar 'car TYPE_LIST))
       (setq TYPE_ITEMS  ;get the name of each type
         (mapcar 'cdr TYPE_LIST))
       (mapcar 'add_list TYPE_ITEMS)
       (end_list)
    )
     
    (defun read-vals()
      (get_tile "type_sel") 
      ;add test for item_num nll
      (if (null ITEM_NUM) (setq ITEM_NUM "0"))
      (setq PRE_FIX (nth (read ITEM_NUM) TYPE_NUMS))
      (setq SUF_FIX (get_tile "size_sel"))
    )
     
    ;-------main program begins here
       (defun err (A)				; internal error handler
          (if (/= A "Function cancelled")
            (princ (strcat "\nError: " A)))
            (resetv)
            (setq *error* ER)
            (prin1)); end defun err
       (command "UNDO" "MARK")
       (setq ER *error* 		
             *error* err) 		
       (savev '("CMDECHO" "OSMODE" "BLIPMODE" 
                "ATTREQ" "CLAYER"))		
     
      (setq DCL_ID (load_dialog "notest.dcl"))
      (if (not (new_dialog "notest" DCL_ID) ) (exit))
      (makelist)  
      (set_tile "size_sel" "SIZE01")
      (set_tile "type_sel" "TYPE01") 
      
      (setq OKFLAG nil)
    ;----user dialog
      (action_tile "type_sel" "(setq ITEM_NUM $value)")
      (action_tile "accept" "(progn (setq OKFLAG T)(read-vals)(done_dialog 1))")
      (start_dialog)
      (unload_dialog DCL_ID)
    ;----check values, make changes
      (if OKFLAG ;this doesn't run if cancelled
         (progn 
            (setq KEY (strcat PRE_FIX "-" SUF_FIX)) 
            (setq BN (getval KEY LOOKUP_LIST))
            (if (null BN)
               (progn
                  (prompt
                     (strcat "\nKey " KEY " not found on lookup_list in notest.lsp.")
                  )
                  (exit)
            ));end if
                  
            (if 			;check to see if block exists
              (or 
                 (tblsearch "block" BN)	
                 (findfile (strcat BN ".dwg"))
              );end or
    	  (progn 
                 (setvar "ATTREQ" 0)
                 (setvar "BLIPMODE" 0)
                 (setvar "CMDECHO" 0)
                 (setvar "OSMODE" 0) 			
                 (lmake "T") 		
                 (setq tm (getvar "TILEMODE"))
     
        (progn
          (if (=  (getvar "USERR3") 0)(setvar "USERR3" 1))
          (if (=  tm 0)(setq sf 1))
          (if (=  tm 1)(setq sf (getvar "USERR3")))
        );end progn
    	    
               (prompt (strcat  
                  "\nInserting DEC Standard Notes: " BN
                 ));end prompt
     
              (setq pt1 (getpoint "\nInsertion Point:"))
                 (command "INSERT" BN pt1 sf "" 0)     
              );end progn
    	  
              (prompt (strcat "\nBlock " BN " not found."))
            );end if
          );end progn
      );end if
      (resetv)
      (setq *error* ER)
      (prin1)
    );end defun c:notest
     
    (prin1)
    
    
    //   notest.DCL   
    //---------------------------------------------------------------------------
    // notest.DCL (Insert DEC Standard Notes)	
    //----------------------------------------------------------------------------
     
    // Corresponding dialogue for notest.LSP 
    // 
    //----------------------------------------------------------------------------
     
    notest : dialog {
        label = "Insert DEC Standard Notes";
        : row { 
          : boxed_column {
              label = " &Discipline:";
            : list_box {
                    key = "type_sel";
    	        alignment = left;
    		fixed_width = true;
                    width = 30;
                    height = 10;
                    multiple_select = false;
            }
          }//end boxed_column
            : boxed_column {
              label = " &Note:";
            : list_box {
                    key = "size_sel";
    	        alignment = left;
    		fixed_width = true;
                    width = 30;
                    height = 10;
                    multiple_select = false;
             }
          } //end boxed_column
        }//end row
        ok_cancel;
    }//end dialog
    Last edited by RobertB; 2009-05-06 at 12:13 AM. Reason: Added code tags

  2. #2
    Active Member
    Join Date
    2015-08
    Posts
    59
    Login to Give a bone
    0

    Default Re: LSP editer novice needs some help.....

    Can't test the code without the contents of your (loadlib).
    steveo

    Quote Originally Posted by djenkins.217096 View Post
    Ok I am trying to make a selection window where on the left you can choose a discipline and on the right you could chose from a selection of notes having to do with that discipline. I almost have the right code but the notes list won’t show up I was hoping someone that knows the lisp code could maybe point out my errors in this lisp routine I have copied and tweaked.
    Last edited by RobertB; 2009-05-06 at 06:13 PM. Reason: Removed quoted code

  3. #3
    Member
    Join Date
    2009-05
    Posts
    10
    Login to Give a bone
    0

    Default Re: LSP editer novice needs some help.....

    Code:
    ;----------------------------------------------------------------------------
    ; LOADLIB.LSP	                    	Copyright (C) 1998 by Jerry Sullivan
    ;----------------------------------------------------------------------------
    ; Permission to use, copy, modify, and distribute this software and its
    ; documentation for any purpose and without fee is hereby granted provided
    ; provided that the copyright notice and limited warranty notice are retained
    ; in the document.  
    ; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
    ;----------------------------------------------------------------------------
    
    ;subroutine loadlib.lsp
    ;checks to see if function is loaded.
    ;if not, loads if from lisp directory
    
    (defun loadlib (STR)
      (if (not LISP_DIR)(setq LISP_DIR ""))
      (if (not (eval (read STR)))
        (progn 
           (if (= "C:" (strcase (substr STR 1 2)))
              (setq STR (substr STR 3))
           );end if
           (prompt (strcat "\nLoading " STR ".lsp ..."))
           (load (strcat LISP_DIR STR))
        );end progn
        (prompt (strcat "\n" STR ".lsp already loaded."))
      );end if
      (prin1)
    );end defun
    Last edited by Opie; 2009-05-06 at 03:04 PM. Reason: [code] tags added

  4. #4
    Member
    Join Date
    2009-05
    Posts
    10
    Login to Give a bone
    0

    Default Re: LSP editer novice needs some help.....

    ....so no one can help?

  5. #5
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: LSP editer novice needs some help.....

    You've got 1 of 2 options. Either populate the size_sel listbox the same way you do with the type_sel listbox (inside the makelist function); or change the action on the type_sel listbox to generate the size_sel dynamically.

    The 1st solution (easiest) would work if you always have all permutations of the various type-size combinations available. But I think the 2nd option is the way to go in all instances. Basically the (action_tile "type_sel" "(setq ITEM_NUM $value)") line needs to include some code to start_list on size_sel, generate the possible sizes using add_list, then end_list. At the moment it simply sets the ITEM_NUM to the text value of the index number selected in the type_sel list box.

Similar Threads

  1. 2013: Best PDF Printer/Editer for Revit 2013?
    By arb in forum Revit Architecture - General
    Replies: 11
    Last Post: 2012-06-01, 07:16 PM
  2. GIS novice
    By cassiopeia in forum Geospatial - General
    Replies: 2
    Last Post: 2011-07-08, 05:12 PM
  3. Still a novice. Need a solution.
    By csf in forum Dynamic Blocks - Technical
    Replies: 7
    Last Post: 2009-02-25, 07:24 PM
  4. Novice
    By comical_wenger in forum AutoCAD General
    Replies: 7
    Last Post: 2008-12-16, 04:14 PM
  5. Hatch editer, interim solution
    By Andre Baros in forum Revit Architecture - Wish List
    Replies: 7
    Last Post: 2005-07-20, 08:29 PM

Posting Permissions

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