Author Topic: i am trying to make a lisp routine  (Read 6310 times)

0 Members and 1 Guest are viewing this topic.

lupes

  • Guest
Re: i am trying to make a lisp routine
« Reply #15 on: February 09, 2006, 03:34:55 PM »
well after messing with this routine I am still in a stump of how to make this thing insert what I want to insert.  I have gotten it a little farther since you guys have helped me but I am still stuck.  Some advice would be most appreciative.

This is what I have so far:

Code: [Select]
;  extra.LSP     LB Industrial Systems Library  (C)2006

  ;extra.LSP Version 0
  ;(C) Copyright 2006 By Guadalupe Stewart
  ;E-mail: lstewart@lbindustrialsystems.com
;;----------------------------------------------------------------------;
  ;Rev. 0                         
;;----------------------------------------------------------------------;
  ;--------------------------INTERNAL ERROR HANDLER---------------------;
(defun
   extra_ERR (MSG)
  (if (or (/= MSG "Function cancelled")
  ; If an error (such as ESC) occurs
          (= MSG "quit / exit abort")
      ) ;_ end of or
    (princ)
    (princ (strcat "\nError: " MSG))
  ) ; while this command is active...
  (setq *ERROR* OLDERR) ; Restore old *error* handler
  (princ)
) ;end extra_ERR   
  ;--------------------------------------------------------------------;
(setq Path "J:/Drawing Standards/Symbols/"); Path to blocks
; New Functions:
(defun get_block_list ( which )
 (cond
  ((= which 1); title blocks
  (setq block_lst (list
    "LBIS Title Block"
    "Presentation Title Block"
    "8 1/2 x 11 Title Block"
    "8 1/2 x 11 Presentation"
    "LBIS Project Schedule"
  ));  setq/list
  ); which 1
; New Functions:
  ((= which 2); Weldneck Flanges
  (setq block_lst (list
    "1/2 in weldneck"
    "3/4 in weldneck"
    "1 in weldneck"
    "1 1/4 in weldneck"
    "1 1/2 in weldneck"
    "2 in weldneck"
    "2 1/2 in weldneck"
    "3 in weldneck"
    "3 1/2 in weldneck"
    "4 in weldneck"
    "5 in weldneck"
    "6 in weldneck"
    "8 in weldneck"
    "10 in weldneck"
    "12 in weldneck"
    "14 in weldneck"
    "16 in weldneck"
    "18 in weldneck"
    "20 in weldneck"
    "22 in weldneck"
    "24 in weldneck"
  ));  setq/list
  ); which 2
; New Functions:
  ((= which 3); Expansion Joints
  (setq block_lst (list
    "2 in expansion"
    "4 in expansion"
    "6 in expansion"
    "8 in expansion"
    "10 in expansion"
    "12 in expansion"
  ));  setq/list
  ); which 3
 ); cond
); function
(defun fill_lst ()
(start_list "get_size")
(mapcar 'add_list block_lst)
(end_list)
); end function
;;-----------------

(defun extra_DIALOG ()
  (setq DCL_ID (load_dialog "extra.dcl"))             
  (if (not (new_dialog "extra" DCL_ID))               
    (exit)                                             
  )                                                   
  (setq blockname ""
        Dia_Abort 0
        what_next 0                                                                                       

  (while (/= what_next 4)
    (action_tile
      "title_block"
      "(setq blockname (nth (atoi (setq _j $key)) blocks_lst))(done_dialog 4)"
)
;; typical action (action_tile "key_name_of_button_x" "(get_block_list N)(fill_lst)")
    (action_tile "titleblocks" "(get_block_list 1) (fill_lst)")                                     
    (action_tile "weldneck_flanges" "(get_block_list 2)(fill_lst)")
    (action_tile "Expansion_Joints" "(get_block_list 3)(fill_lst)")
    (action_tile "insert" "(setq Dia_Abort 1)(done_dialog 4)")                                     
    (action_tile "accept" "(done_dialog 4)")
    (action_tile "cancel" "(setq Dia_Abort 1)(done_dialog 4)")
    (action_tile "extra_help" "(extra_help)")
    (setq what_next (start_dialog ))                          ;display the dialog box       
  ); while
   (unload_dialog DCL_ID) ;unload the DCL file
;;-----------------
   (if (and (/= blockname "")(/= Dia_Abort 1))
    (progn
     (if (findfile (strcat Path blockname ".dwg"))
      (progn
         (setvar "attreq" 1)
         (initdia)
         (command "-INSERT" (strcat Path blockname) pause "1" "1" "0") ; insert the block / FILL attrib's/
      ); progn
       (alert (strcat "Could not locate Blockname " blockname ".dwg"))
     ); if
    ); progn
   ); if
 (princ)
) ;end extra_DIALOG
  ;--------------------------------------------------------------------;
(defun
   C:extra ()
  (setq
    OLDERR *ERROR*
    *ERROR* extra_ERR
  ) ;_ end of setq
  (extra_DIALOG)
  (princ)
) ;end extra
(princ "\nLB Industrial Systems Library Loaded. Type extra to use.")
(princ)

Code tags added
« Last Edit: February 09, 2006, 04:31:08 PM by CAB »

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: i am trying to make a lisp routine
« Reply #16 on: February 10, 2006, 09:36:35 AM »
lupes, you've been asked a few times to post the DCL file. Without it we cannot test run the code to see where it's failing.

lupes

  • Guest
Re: i am trying to make a lisp routine
« Reply #17 on: February 16, 2006, 05:22:40 PM »
sorry about that here is the dcl file.
and a revised lisp routine.


//Tip1779:  extra.DCL     LB Library  (C)2006, Guadalupe Stewart

dcl_settings : default_dcl_settings { audit_level = 0; }

extra : dialog {
   label = "LB Industrial Systems Library of Blocks";
   : text {
     label = "Version 0 (C) 2006 by Guadalupe Stewart";
   }
   : row {
      children_alignment = top;
      :column {
      : boxed_column {
         label = "Title Blocks ";
         : button {
         key = "titleblocks";
         label = "Title Blocks";
         }
      }
      : boxed_column {
         label = "Flange_Items";
         : button {
         key = "weldneck_flanges";
         label = "Weldneck Flanges";
         }
         : button {
         key = "Expansion_Joints";
         label = "Expansion Joints";
         }
      }
      : boxed_column {
         label = "Valves";
         : button {
         key = "Automatic_Butterfly_Valves";
         label = "Automatic Butterfly Valves";
         }
         : button {
         key = "Manual_Butterfly_Valves";
         label = "Manual Butterfly Valves";
         }
         : button {
         key = "Everlasting_Valves";
         label = "Everlasting Valves";
         }
         : button {
         key = "Automatic_Knifegate_Valves";
         label = "Automatic Knifegate Valves";
         }
         : button {
         key = "Manual_Knifegate_Valves";
         label = "Manual Knifegate Valves";
         }
      }
      : boxed_column {
         label = "Sch 40 Fittings";
         : button {
         key = "90_deg_elbows";
         label = "90 deg elbows";
         }
         : button {
         key = "45_deg_elbows";
         label = "45 deg elbows";
         }
         : button {
         key = "tees";
         label = "tees";
         }
         : button {
         key = "laterals";
         label = "laterals";
         }
         : button {
         key = "unions";
         label = "unions";
         }
         : button {
         key = "Concentric_Reducers";
         label = "Concentric Reducers";
         }
      }
                }
      :column {
      : boxed_column {
         label = "Pipe Supports";
         : button {
         key = "U_Bolts";
         label = "U Bolts";
         }
         : button {
         key = "Clevis";
         label = "Clevis";
         }
         : button {
         key = "Beam_Attachments";
         label = "Beam Attachments";
         }
         : button {
         key = "Riser_Clamps";
         label = "Riser Clamps";
         }
      }
      : boxed_column {
         label = "Couplings";
         : button {
         key = "Socket_Weld_ Couplings";
         label = "Socket Weld Couplings";
         }
         : button {
         key = "Threaded_ Couplings";
         label = "Threaded Couplings";
         }
      }
      : boxed_column {
         label = "Miscellaneous Items";
         : button {
         key = "Miscellaneous_Items";
         label = "Miscellaneous Items";
         }
         : button {
         key = "Instrument_Air";
         label = "Instrument Air";
         }
         : button {
         key = "PID Symbols";
         label = "PID Symbols";
         }
         : button {
         key = "PID_Assemblies";
         label = "PID Assemblies";
         }
         : button {
         key = "Weld_Symbols";
         label = "Weld Symbols";
         }
      }
      : boxed_column {
         label = "Fittings";
         : button {
         key = "Hardened Fittings";
         label = "Hardened Fittings";
         }
         : button {
         key = "Threaded Fittings";
         label = "Threaded Fittings";
         }
                }
                }
      : column {
      fixed_height = true;
         : list_box {
         label = "Blocks";
         width = 25;
         height = 35;
         key = "get_size";
         }
      }
   }
   :row { }
:row {
fixed_width = true;
alignment = centered;
ok_cancel;
: button {
  label = "Help";
  fixed_width =  true;
  key = "extra_help";
  }
}
}

extra_help : dialog {
label = "Help for extra";

: list_box {
width =  100;
height =  25;
fixed_height =  true;
key = "extra_help";
}
ok_cancel;
}


;  extra.LSP     LB Industrial Systems Library  (C)2006

  ;extra.LSP Version 0
  ;(C) Copyright 2006 By Guadalupe Stewart
  ;E-mail: lstewart@lbindustrialsystems.com
;;----------------------------------------------------------------------;
  ;Rev. 0                         
;;----------------------------------------------------------------------;
  ;--------------------------INTERNAL ERROR HANDLER---------------------;
(defun
   extra_ERR (MSG)
  (if (or (/= MSG "Function cancelled")
  ; If an error (such as ESC) occurs
          (= MSG "quit / exit abort")
      ) ;_ end of or
    (princ)
    (princ (strcat "\nError: " MSG))
  ) ; while this command is active...
  (setq *ERROR* OLDERR) ; Restore old *error* handler
  (princ)
) ;end extra_ERR   
  ;--------------------------------------------------------------------;
(setq Path "J:/Drawing Standards/Symbols/"); Path to blocks
; New Functions:
(defun get_block_list ( which )
 (cond
  ((= which 1); title blocks
  (setq block_lst (list
    "LBIS Title Block"
    "Presentation Title Block"
    "8 1/2 x 11 Title Block"
    "8 1/2 x 11 Presentation"
    "LBIS Project Schedule"
  ));  setq/list
  ); which 1
; New Functions:
  ((= which 2); Weldneck Flanges
  (setq block_lst (list
    "1/2 in weldneck"
    "3/4 in weldneck"
    "1 in weldneck"
    "1 1/4 in weldneck"
    "1 1/2 in weldneck"
    "2 in weldneck"
    "2 1/2 in weldneck"
    "3 in weldneck"
    "3 1/2 in weldneck"
    "4 in weldneck"
    "5 in weldneck"
    "6 in weldneck"
    "8 in weldneck"
    "10 in weldneck"
    "12 in weldneck"
    "14 in weldneck"
    "16 in weldneck"
    "18 in weldneck"
    "20 in weldneck"
    "22 in weldneck"
    "24 in weldneck"
  ));  setq/list
  ); which 2
; New Functions:
  ((= which 3); Expansion Joints
  (setq block_lst (list
    "2 in expansion"
    "4 in expansion"
    "6 in expansion"
    "8 in expansion"
    "10 in expansion"
    "12 in expansion"
  ));  setq/list
  ); which 3
; New Functions:
  ((= which 4); Automatic Butterfly Valves
  (setq block_lst (list
    "2 in butterfly"
    "2 1/2 in butterfly"
    "3 in butterfly"
    "4 in butterfly"
    "5 in butterfly"
    "6 in butterfly"
    "8 in butterfly"
    "10 in butterfly"
    "12 in butterfly"
  ));  setq/list
  ); which 4
; New Functions:
  ((= which 5); Manual Butterfly Valves
  (setq block_lst (list
    "2 in butterfly"
    "2 1/2 in butterfly"
    "3 in butterfly"
    "4 in butterfly"
    "5 in butterfly"
    "6 in butterfly"
    "8 in butterfly"
    "10 in butterfly"
    "12 in butterfly"
  ));  setq/list
  ); which 5
; New Functions:
  ((= which 6); Everlasting Valves
  (setq block_lst (list
    "2 in everlasting"
    "2 1/2 in everlasting"
    "3 in everlasting"
    "4 in everlasting"
    "5 in everlasting"
    "6 in everlasting"
    "8 in everlasting"
    "10 in everlasting"
    "12 in everlasting"
  ));  setq/list
  ); which 6
 ); cond
); function
(defun fill_lst ()
(start_list "get_size")
(mapcar 'add_list block_lst)
(end_list)
); end function
;;-----------------

(defun extra_DIALOG ()
  (setq DCL_ID (load_dialog "extra.dcl"))             
  (if (not (new_dialog "extra" DCL_ID))               
    (exit)                                             
) ;end if                                                   
  (setq blockname ""
        Dia_Abort 0
        what_next 0
)
  (while (/= what_next 4)
    (action_tile
      "title_block"
      "(setq blockname (nth (atoi (setq _j $valve)) blocks_lst))(done_dialog 4)"
)
;; typical action (action_tile "key_name_of_button_x" "(get_block_list N)(fill_lst)")
    (action_tile "titleblocks" "(get_block_list 1) (fill_lst)")                                     
    (action_tile "weldneck_flanges" "(get_block_list 2)(fill_lst)")
    (action_tile "Expansion_Joints" "(get_block_list 3)(fill_lst)")
    (action_tile "Automatic_Butterfly_Valves" "(get_block_list 4)(fill_lst)")
    (action_tile "Manual_Butterfly_Valves" "(get_block_list 5)(fill_lst)")
    (action_tile "Everlasting_Valves" "(get_block_list 6)(fill_lst)")                                     
    (action_tile "accept" "(done_dialog 4)")
    (action_tile "cancel" "(setq Dia_Abort 1)(done_dialog 4)")
    (action_tile "extra_help" "(extra_help)")
    (setq what_next (start_dialog ))                          ;display the dialog box       
  ); while
   (unload_dialog DCL_ID) ;unload the DCL file
   (if (and (/= blockname "")(/= Dia_Abort 1))
    (progn
     (if (findfile (strcat Path blockname ".dwg"))
      (progn
         (setvar "attreq" 1)
         (initdia)
         (command "-INSERT" (strcat Path blockname) pause "1" "1" "0") ; insert the block / FILL attrib's
      ); progn
       (alert (strcat "Could not locate Blockname " blockname ".dwg"))
     ); if
    ); progn
   ); if
 (princ)
) ;end extra_DIALOG
  ;--------------------------------------------------------------------;
(defun
   C:extra ()
  (setq
    OLDERR *ERROR*
    *ERROR* extra_ERR
  ) ;end of setq
  (extra_DIALOG)
  (princ)
) ;end extra
(princ "\nLB Industrial Systems Library Loaded. Type extra to use.")
(princ)



Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: i am trying to make a lisp routine
« Reply #18 on: February 16, 2006, 06:20:37 PM »
Changing this line from
Code: [Select]
(action_tile
      "title_block"
      "(setq blockname (nth (atoi (setq _j $valve)) blocks_lst))(done_dialog 4)"
)
to this
Code: [Select]
(action_tile
      "get_size"
      "(setq blockname (nth (atoi (setq _j $value)) block_lst))(done_dialog 4)")
allowed me to at least get to the "Block not found" alert....which would be expected since I don't have your blocks or path to them.

HTH,
Jeff

lupes

  • Guest
Re: i am trying to make a lisp routine
« Reply #19 on: February 17, 2006, 11:04:57 AM »
HOK THAT SOUNDS GOOD HERE ARE SOME BLOCKS THAT I HAVE.  I THANK Y'ALL FOR ALL THE HELP AND GUIDANCE THAT Y'ALL HAVE PROVIDED AND IT IS GREATLY APPRECIATED!!

IF YOU NEED MORE BLOCKS JUST LE ME KNOW

GDF

  • Water Moccasin
  • Posts: 2081
Re: i am trying to make a lisp routine
« Reply #20 on: February 17, 2006, 11:19:40 AM »
You might want to consider using slides to help identify block names. I would have the slide popup whenever an item in the list_box is made.


Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

lupes

  • Guest
Re: i am trying to make a lisp routine
« Reply #21 on: February 17, 2006, 11:58:35 AM »
man that routine looks good.  but that routine is copy written huh.

GDF

  • Water Moccasin
  • Posts: 2081
Re: i am trying to make a lisp routine
« Reply #22 on: February 17, 2006, 12:41:40 PM »
I'm not the best code writer, but here is how I got the slides from a slide library.

Code: [Select]
           
from the dcl file:
:image {key = "shpimg"; width=14; height=4.75; color=-15;}   

from the lisp file:
(defun MECHIMAGEX (/ shpimx shpimy shimg)
  (setq shimg sufmech)
  (setq shpimx (dimx_tile "shpimg")
shpimy (dimy_tile "shpimg")
  )
  (start_image "shpimg")
  (fill_image 0 0 shpimx shpimy -15)
  ;;this resets the slide image! 
  (slide_image
    0
    -5
    shpimx
    shpimy
    (strcat ARCH#CUSF "MECH/" "MECH(" shimg ")")
  )
  (end_image)
  (set_tile "type-list" (rtos mechinx 2 0))
)

(defun MECHIMAGE (/ shpimx shpimy shimg)
  (cond
    ((= mechinx 0) (setq sufmech "24DifF") (MECH-DifFUSER))
    ((= mechinx 1) (setq sufmech "RDDN") (MECH-ELBOWS))
    ((= mechinx 2) (setq sufmech "DTAP") (MECH-TAPS))
    ((= mechinx 3) (setq sufmech "FPVAV") (MECH-FPVAV))
    ((= mechinx 4) (setq sufmech "VAV") (MECH-VAV))
    ((= mechinx 5) (setq sufmech "TRANERTU") (MECH-TRANERTU))
    ((= mechinx 6) (setq sufmech "500T") (MECH-SCHEMATIC))
    ((= mechinx 7) (setq sufmech "TUP") (MECH-SNGPIPE))
    ((= mechinx 8) (setq sufmech "BFV") (MECH-DBLPIPE))
  )
  (setq shimg sufmech)
  (setq shpimx (dimx_tile "shpimg")
shpimy (dimy_tile "shpimg")
  )
  (start_image "shpimg")
  (fill_image 0 0 shpimx shpimy -15)
  ;;this resets the slide image!
  (slide_image
    0
    -5
    shpimx
    shpimy
    (strcat ARCH#CUSF "MECH/" "MECH(" shimg ")")
  )
  (end_image)
  (set_tile "type-list" (rtos mechinx 2 0))
  (set_tile
    "set-title"
    (strcat ARCH#LOGO
    " : MECH                          Mechanical Plumbing : "
    listname
    )
  )
)


(defun MECH-DifFUSER (/ xxx)
  (mode_tile "accept" 0)
  (setq SET_MECHWIDTH
'("Supply"    "Return"    "Slot"
   "Slot 8"    "Supply <---"   "Return --->"
   "Flex Duct..."
  )
  )
  (defun GET_MECHWIDTH ()
    (cond
      ((= XXX 0)
       (setq MECHBLOCK "MECH_DifFUSER/24DifF")
       (setq sufmech "24DifF")
       (MECHIMAGEX)
       (ARCH:SETMECHMODE "4")
      )
      ((= XXX 1)
       (setq MECHBLOCK "MECH_DifFUSER/24RTN")
       (setq sufmech "24RTN")
       (MECHIMAGEX)
       (ARCH:SETMECHMODE "1")
      )
      ((= XXX 2)
       (setq MECHBLOCK "MECH_DifFUSER/LSD")
       (setq sufmech "LSD")
       (MECHIMAGEX)
       (ARCH:SETMECHMODE "1")
      )
      ((= XXX 3)
       (setq MECHBLOCK "MECH_DifFUSER/LSD8")
       (setq sufmech "LSD8")
       (MECHIMAGEX)
       (ARCH:SETMECHMODE "1")
      )
...and so on

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

lupes

  • Guest
Re: i am trying to make a lisp routine
« Reply #23 on: February 17, 2006, 03:28:29 PM »
do you know what the command that this routine uses to insert the individual drawings that you have made. because that is the trouble that i am having.  I got the menu to load and show what it is suppose to show, I got it to select the block that I want but I have been trying for a while now to make the block insert into the autocad session.

I am going to try that part about the slide look because that looks pretty slick.  as an extra look for the routine.


thanks for the idea.

Lupe

GDF

  • Water Moccasin
  • Posts: 2081
Re: i am trying to make a lisp routine
« Reply #24 on: February 17, 2006, 04:15:05 PM »
oops

wrong image, here is the block one...
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

hyposmurf

  • Guest
Re: i am trying to make a lisp routine
« Reply #25 on: February 17, 2006, 05:19:01 PM »
Your images of your pop dialogue boxes with all those buttons. :love: Looks like were from the same industry.Have you ever marketed your work?

GDF

  • Water Moccasin
  • Posts: 2081
Re: i am trying to make a lisp routine
« Reply #26 on: February 17, 2006, 06:15:37 PM »
It's free. What I have is highly customized to meet our office CAD standards.

However it is part of an overall program (non standalone for individual lisp routines).
I would have to send all or nothing for it to work.

Even the dcl widgets are in a seperate file and loaded using:
//To load master widgets used by Arch Program© for AutoCAD®
@include "..\\ARCH.dcl"

Parts of it could be easily customized to you standards, for ex: "LAYS" layer xxx.lay files

Does any of this make since? The whole routine plus generic blocks just fits on one CD.
I've gone down the path of no return....everthing is linked together.

I have thought about mailing out a CD of what I have. If anyone is interested, just send me
your mailing address and, I will send you the CD.

I will do this for the first three emails I get. I do have a day job.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64