Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I need help creating an AutoCAD LISP Routine for Isometric Pipe Drawings

7 REPLIES 7
Reply
Message 1 of 8
JZelayaABS
2840 Views, 7 Replies

I need help creating an AutoCAD LISP Routine for Isometric Pipe Drawings

Hello to All,

 

I need help and I do not know where to begin. I want to set up LISP routines for 2D isometric pipe drawings. For example, being able to add Gate valves, ball valves, globe balls, etc. to drawings by simply pressing an icon button on the toolbar.

 

I have already created these many valves as blocks,

 

Something else that I would love to do, is to add these valves on lines and trim the line between the flanges surrounding the valve. Also being able to change the plane it is on and be able to add the size of the valve underneath the valve symbol.

 

If ANYONE can help me out that would be great or point me in the right direction. I would really appreciate it!

 

Regards,

 

Jorge

7 REPLIES 7
Message 2 of 8
bhull1985
in reply to: JZelayaABS

Have fun adapting this for your own needs/blocks.

(defun c:manualvalves (/ Dcl_Id% Folder$ Slides@ Slide1$ Slide2$ Slide3$ Slide4$ Slide5$ Slide6$ Slide7$ Slide8$ Slide9$ Slide10$ Slide11$ Slide12$ Slide13$ Slide14$ Slide15$ Slide16$ X# Y# ss a1 a2 a3 p2 p3 insertpt1 osm *error*)




  (command "_.undo" "_begin")


 (defun *error* ( msg )
      (if osm (setvar 'OSMODE osm))
      (if snpm (setvar 'SNAPMODE snpm))
      (if snp (command "snap" snp))
      (if echo (setvar 'CMDECHO echo))

    (if (not (member msg '("Function cancelled" "quit / exit abort")))
        (princ (strcat "\nError: " msg))
    )
    (princ)
    (command "_.undo" "_end")
    )



   (princ "\n*************************************")(princ)
   (princ "\n********Manual Valves Dialog*********")(princ)
;   (princ "\n**********L-Con Engineering**********")(princ)
;   (princ "\n********B. Hull C. Helms 2013********")(princ)
   (princ "\n*************************************")(princ "\n")
    ; Set Default Variables
   (setq Slides@ (list nil "ANGLE VALVE" "BALL VALVE WITH BLEED VALVE" "BALL VALVE" "BUTTERFLY VALVE" "CHECK VALVE" "BUTTERFLY ON-OFF VALVE" "DIAPHRAGM VALVE" "GATE VALVE WITH BLEED VALVE" "GATE VALVE" "GLOBE VALVE" "NEEDLE VALVE" "PLUG VALVE" "ROTARY VALVE" "THREE-WAY VALVE" "THREE-WAY BALL VALVE" "FOUR-WAY VALVE")
         Slide1$ (nth 1 Slides@)
         Slide2$ (nth 2 Slides@)
         Slide3$ (nth 3 Slides@)
         Slide4$ (nth 4 Slides@)
         Slide5$ (nth 5 Slides@)
         Slide6$ (nth 6 Slides@)
         Slide7$ (nth 7 Slides@)
         Slide8$ (nth 8 Slides@)
         Slide9$ (nth 9 Slides@)
         Slide10$ (nth 10 Slides@)
         Slide11$ (nth 11 Slides@)
         Slide12$ (nth 12 Slides@)
         Slide13$ (nth 13 Slides@)
         Slide14$ (nth 14 Slides@)
         Slide15$ (nth 15 Slides@)
         Slide16$ (nth 16 Slides@)
         Folder$ ""
         Return$ ""
   );setq
    ; Load Dialog

   (setq Dcl_Id% (load_dialog "manualvalves.dcl"))

   (new_dialog "manualvalves" Dcl_Id%)

    ; Set Dialog Initial Settings
   (set_tile "Title" "MANUALLY OPERATED VALVES")
   (set_tile "ANGLE VALVE" Slide1$)
   (set_tile "BALL VALVE WITH BLEED VALVE" Slide2$)
   (set_tile "BALL VALVE" Slide3$)
   (set_tile "BUTTERFLY VALVE" Slide4$)
   (set_tile "CHECK VALVE" Slide5$)
   (set_tile "BUTTERFLY ON-OFF VALVE" Slide6$)
   (set_tile "DIAPHRAGM VALVE" Slide7$)
   (set_tile "GATE VALVE WITH BLEED VALVE" Slide8$)
   (set_tile "GATE VALVE" Slide9$)
   (set_tile "GLOBE VALVE" Slide10$)
   (set_tile "NEEDLE VALVE" Slide11$)
   (set_tile "PLUG VALVE" Slide12$)
   (set_tile "ROTARY VALVE" Slide13$)
   (set_tile "THREE-WAY VALVE" Slide14$)
   (set_tile "THREE-WAY BALL VALVE" Slide15$)
   (set_tile "FOUR-WAY VALVE" Slide16$)

    ; Adjust X# and Y# per image_buttom outline to fit slide_image
   (start_image "Slide1")
   (setq X# (- (dimx_tile "Slide1") 2))
   (setq Y# (- (dimy_tile "Slide1") 2))
   (end_image)
   (start_image "Slide1")(slide_image 1 1 X# Y# (strcat Folder$ Slide1$))(end_image)
   (start_image "Slide2")(slide_image 1 1 X# Y# (strcat Folder$ Slide2$))(end_image)
   (start_image "Slide3")(slide_image 1 1 X# Y# (strcat Folder$ Slide3$))(end_image)
   (start_image "Slide4")(slide_image 1 1 X# Y# (strcat Folder$ Slide4$))(end_image)
   (start_image "Slide5")(slide_image 1 1 X# Y# (strcat Folder$ Slide5$))(end_image)
   (start_image "Slide6")(slide_image 1 1 X# Y# (strcat Folder$ Slide6$))(end_image)
   (start_image "Slide7")(slide_image 1 1 X# Y# (strcat Folder$ Slide7$))(end_image)
   (start_image "Slide8")(slide_image 1 1 X# Y# (strcat Folder$ Slide8$))(end_image)
   (start_image "Slide9")(slide_image 1 1 X# Y# (strcat Folder$ Slide9$))(end_image)
   (start_image "Slide10")(slide_image 1 1 X# Y# (strcat Folder$ Slide10$))(end_image)
   (start_image "Slide11")(slide_image 1 1 X# Y# (strcat Folder$ Slide11$))(end_image)
   (start_image "Slide12")(slide_image 1 1 X# Y# (strcat Folder$ Slide12$))(end_image)
   (start_image "Slide13")(slide_image 1 1 X# Y# (strcat Folder$ Slide13$))(end_image)
   (start_image "Slide14")(slide_image 1 1 X# Y# (strcat Folder$ Slide14$))(end_image)
   (start_image "Slide15")(slide_image 1 1 X# Y# (strcat Folder$ Slide15$))(end_image)
   (start_image "Slide16")(slide_image 1 1 X# Y# (strcat Folder$ Slide16$))(end_image)

     ; Dialog Actions
	(action_tile "Slide1" "(done_dialog 11)")
	(action_tile "Slide2" "(done_dialog 12)")
	(action_tile "Slide3" "(done_dialog 13)")
	(action_tile "Slide4" "(done_dialog 14)")
	(action_tile "Slide5" "(done_dialog 15)")
	(action_tile "Slide6" "(done_dialog 16)")
	(action_tile "Slide7" "(done_dialog 17)")
	(action_tile "Slide8" "(done_dialog 18)")
	(action_tile "Slide9" "(done_dialog 19)")
	(action_tile "Slide10" "(done_dialog 20)")
	(action_tile "Slide11" "(done_dialog 21)")
	(action_tile "Slide12" "(done_dialog 22)")
	(action_tile "Slide13" "(done_dialog 23)")
	(action_tile "Slide14" "(done_dialog 24)")
	(action_tile "Slide15" "(done_dialog 25)")
	(action_tile "Slide16" "(done_dialog 26)")
	(action_tile "cancel" "(done_dialog 0)")
  
(setq a1 (start_dialog))
(setq osm (getvar "osmode"))
(command "attreq" "0")

(if (and a1 (> a1 1))
 (progn
	(command "snap" "0.0625")
(if (/= 16384 (logand 16384 (getvar "osmode")))						;set osmode
(setvar "osmode" (boole 6 (getvar "osmode") 16384))					;set osmode
)											;if
(setvar "osmode" 0)									;set osmode

                        (if (not (tblsearch "layer" "Pid"))
                            (entmake
                               (list
                                  (cons 0 "Layer")
                                  (cons 100 "AcDbSymbolTableRecord")
                                  (cons 100 "AcDbLayerTableRecord") 
                                  (cons 2 "Pid")
                                  (cons 70 0)
                                  (cons 62 4)
                                  (cons 6 "Continuous")
                                );list
                               );entmake
                          );if

(setvar "clayer" "Pid") 
(if (setq insertpt1 (getpoint "\nPick Insertion Point: "))
(progn
  (if (and (setq name (car (nentselp insertpt1)))
	   (wcmatch (cdr (assoc 0 (entget name)))"LINE,LWPOLYLINE")
	   );; and
    (setq objx 1)
    );; if
      (cond	
	((= a1 11)(MySub "ANGLE VALVE" 0.1250 -0.000001 insertpt1))					;a1 11
	((= a1 12)(MySub "BALL VALVE WITH BLEED VALVE" 0.1250 -0.1250 insertpt1))			;a1 12
	((= a1 13)(MySub "BALL VALVE" 0.1250 -0.1250 insertpt1))					;a1 13
	((= a1 14)(MySub "BUTTERFLY VALVE" 0.1250 -0.1250 insertpt1))					;a1 14
	((= a1 15)(MySub "CHECK VALVE" 0.1250 -0.1250 insertpt1))					;a1 15
	((= a1 16)(MySub "BUTTERFLY ON-OFF VALVE" 0.1250 -0.1250 insertpt1))				;a1 16
	((= a1 17)(MySub "DIAPHRAGM VALVE" 0.1250 -0.1250 insertpt1))					;a1 17
	((= a1 18)(MySub "GATE VALVE WITH BLEED VALVE" 0.1250 -0.1250 insertpt1))			;a1 18
	((= a1 19)(MySub "GATE VALVE" 0.1250 -0.1250 insertpt1))					;a1 19
	((= a1 20)(MySub "GLOBE VALVE" 0.1250 -0.1250 insertpt1))					;a1 20
	((= a1 21)(MySub "NEEDLE VALVE" 0.1250 -0.1250 insertpt1))					;a1 21
	((= a1 22)(MySub "PLUG VALVE" 0.1250 -0.1250 insertpt1))					;a1 22
	((= a1 23)(MySub "ROTARY VALVE" 0.1250 -0.1250 insertpt1))					;a1 23
	((= a1 24)(MySub "THREE-WAY VALVE" 0.1250 -0.1250 insertpt1))					;a1 24
	((= a1 25)(MySub "THREE-WAY BALL VALVE" 0.1250 -0.1250 insertpt1))				;a1 25
	((= a1 26)(MySub "FOUR-WAY VALVE" 0.1250 -0.1250 insertpt1))					;a1 26
       	)												;cond	
       )												;progn
	)												;a1 1 if
	))												;if progn test				
(setvar "osmode" osm)	
(setvar "cmdecho" 1)						
(princ)	
    (command "_.undo" "_end")									
)										

(defun MySub (a1 a2 a3 insertpt1 / OBJ P2 P3)						;subfunction
(vl-load-com)										;load vlisp functions
  (if (= objx 1)									;if flag is raised
    (progn										;do these actions
(setvar "osmode" 0)									;set osnap
(command "_insert" a1 insertpt1 "" "" pause)						;insert and select rotation
									
(if (> a2 0.0)										;if trim dist is greater than 0.0 preform
(progn
(setq obj (vlax-ename->vla-object name))
(if (eq (vla-get-ObjectName obj) "AcDbPolyline")					;; if it is a LwPolyline
     (setq p3 insertpt1
	   p2 (angle insertpt1  (vlax-curve-getpointatparam obj  (fix (vlax-curve-getparamatpoint obj insertpt1)))))		     
(setq p3 insertpt1
      p2 (angle (vlax-curve-getStartpoint obj) (vlax-curve-getEndPoint obj)))
)											;if
(command "break" name (polar p3 p2 a2) (polar p3 p2 a3))
)											;progn
(princ "\n......Selected....\n......Breaking Lines....")				;status
)											;if
)											;progn
(progn											;do these actions
  (command "_insert" a1 insertpt1 "" "" pause)						;insert				
  (princ)										;exit cleanly
)											;progn  
)											;if
(princ "\n......Insertion Completed!")							;print clear to screen
(princ)											;print clear

)											;MySub

 and the accompanying dcl

 

img : image_button
{
	height = 5.5;
	width = 18.00;
	fixed_width = true;
	fixed_height = true;
	alignment = centered;
	color = -2;
}
txt : text {fixed_width = true; alignment = centered; }
col : column {fixed_width = true; width = 35; }

  //---------------------------------------------------------------------------------------------------------
 // Manually Operated Valves Dialog
//	Brandon Hull, Cynthia helms, special thanks to : Lee Mac, Scot65, HmSilva
//		L-Con, 2013
 //---------------------------------------------------------------------------------------------------------
  manualvalves : dialog {
   label = "MANUALLY OPERATED VALVES"; spacer;
	: row 
	{
	   : col
	   {
		: img { key = "Slide1"; } : txt { label = "Angle Valve"; } spacer_1;
		: img { key = "Slide2"; } : txt { label = "Ball Valve w Bleed Valve"; } spacer_1;
		: img { key = "Slide3"; } : txt { label = "Ball Valve"; } spacer_1;
		: img { key = "Slide4"; } : txt { label = "Butterfly Valve"; }
	   }
	   : col
	   {
		: img { key = "Slide5"; } : txt { label = "Check Valve"; } spacer_1;
		: img { key = "Slide6"; } : txt { label = "Butterfly On-Off Valve"; } spacer_1;
		: img { key = "Slide7"; } : txt { label = "Diaphragm Valve"; } spacer_1;
		: img { key = "Slide8"; } : txt { label = "Gate Valve w Bleed Valve"; } 
	   }
	   : col
	   {
		: img { key = "Slide9"; } : txt { label = "Gate Valve"; } spacer_1;
		: img { key = "Slide10"; } : txt { label = "Globe Valve"; } spacer_1;    
		: img { key = "Slide11"; } : txt { label = "Needle Valve"; } spacer_1;
		: img { key = "Slide12"; } : txt { label = "Plug Valve"; } 
	   }
	   : col
	   {
		: img { key = "Slide13"; } : txt { label = "Rotary Valve"; } spacer_1;
		: img { key = "Slide14"; } : txt { label = "Three-Way Valve"; } spacer_1;
		: img { key = "Slide15"; } : txt { label = "Three-Way Ball Valve"; } spacer_1;	
		: img { key = "Slide16"; } : txt { label = "Four-Way Valve"; }
	   }
	}
	spacer; cancel_button;     
}///manualvalves

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 3 of 8
Kent1Cooper
in reply to: JZelayaABS

If you put something like "insert and trim" into the Search window, you'll find a lot of threads about that aspect of it.

Kent Cooper, AIA
Message 4 of 8
JZelayaABS
in reply to: bhull1985


@bhull1985 wrote:

Have fun adapting this for your own needs/blocks.

(defun c:manualvalves (/ Dcl_Id% Folder$ Slides@ Slide1$ Slide2$ Slide3$ Slide4$ Slide5$ Slide6$ Slide7$ Slide8$ Slide9$ Slide10$ Slide11$ Slide12$ Slide13$ Slide14$ Slide15$ Slide16$ X# Y# ss a1 a2 a3 p2 p3 insertpt1 osm *error*)




  (command "_.undo" "_begin")


 (defun *error* ( msg )
      (if osm (setvar 'OSMODE osm))
      (if snpm (setvar 'SNAPMODE snpm))
      (if snp (command "snap" snp))
      (if echo (setvar 'CMDECHO echo))

    (if (not (member msg '("Function cancelled" "quit / exit abort")))
        (princ (strcat "\nError: " msg))
    )
    (princ)
    (command "_.undo" "_end")
    )



   (princ "\n*************************************")(princ)
   (princ "\n********Manual Valves Dialog*********")(princ)
;   (princ "\n**********L-Con Engineering**********")(princ)
;   (princ "\n********B. Hull C. Helms 2013********")(princ)
   (princ "\n*************************************")(princ "\n")
    ; Set Default Variables
   (setq Slides@ (list nil "ANGLE VALVE" "BALL VALVE WITH BLEED VALVE" "BALL VALVE" "BUTTERFLY VALVE" "CHECK VALVE" "BUTTERFLY ON-OFF VALVE" "DIAPHRAGM VALVE" "GATE VALVE WITH BLEED VALVE" "GATE VALVE" "GLOBE VALVE" "NEEDLE VALVE" "PLUG VALVE" "ROTARY VALVE" "THREE-WAY VALVE" "THREE-WAY BALL VALVE" "FOUR-WAY VALVE")
         Slide1$ (nth 1 Slides@)
         Slide2$ (nth 2 Slides@)
         Slide3$ (nth 3 Slides@)
         Slide4$ (nth 4 Slides@)
         Slide5$ (nth 5 Slides@)
         Slide6$ (nth 6 Slides@)
         Slide7$ (nth 7 Slides@)
         Slide8$ (nth 8 Slides@)
         Slide9$ (nth 9 Slides@)
         Slide10$ (nth 10 Slides@)
         Slide11$ (nth 11 Slides@)
         Slide12$ (nth 12 Slides@)
         Slide13$ (nth 13 Slides@)
         Slide14$ (nth 14 Slides@)
         Slide15$ (nth 15 Slides@)
         Slide16$ (nth 16 Slides@)
         Folder$ ""
         Return$ ""
   );setq
    ; Load Dialog

   (setq Dcl_Id% (load_dialog "manualvalves.dcl"))

   (new_dialog "manualvalves" Dcl_Id%)

    ; Set Dialog Initial Settings
   (set_tile "Title" "MANUALLY OPERATED VALVES")
   (set_tile "ANGLE VALVE" Slide1$)
   (set_tile "BALL VALVE WITH BLEED VALVE" Slide2$)
   (set_tile "BALL VALVE" Slide3$)
   (set_tile "BUTTERFLY VALVE" Slide4$)
   (set_tile "CHECK VALVE" Slide5$)
   (set_tile "BUTTERFLY ON-OFF VALVE" Slide6$)
   (set_tile "DIAPHRAGM VALVE" Slide7$)
   (set_tile "GATE VALVE WITH BLEED VALVE" Slide8$)
   (set_tile "GATE VALVE" Slide9$)
   (set_tile "GLOBE VALVE" Slide10$)
   (set_tile "NEEDLE VALVE" Slide11$)
   (set_tile "PLUG VALVE" Slide12$)
   (set_tile "ROTARY VALVE" Slide13$)
   (set_tile "THREE-WAY VALVE" Slide14$)
   (set_tile "THREE-WAY BALL VALVE" Slide15$)
   (set_tile "FOUR-WAY VALVE" Slide16$)

    ; Adjust X# and Y# per image_buttom outline to fit slide_image
   (start_image "Slide1")
   (setq X# (- (dimx_tile "Slide1") 2))
   (setq Y# (- (dimy_tile "Slide1") 2))
   (end_image)
   (start_image "Slide1")(slide_image 1 1 X# Y# (strcat Folder$ Slide1$))(end_image)
   (start_image "Slide2")(slide_image 1 1 X# Y# (strcat Folder$ Slide2$))(end_image)
   (start_image "Slide3")(slide_image 1 1 X# Y# (strcat Folder$ Slide3$))(end_image)
   (start_image "Slide4")(slide_image 1 1 X# Y# (strcat Folder$ Slide4$))(end_image)
   (start_image "Slide5")(slide_image 1 1 X# Y# (strcat Folder$ Slide5$))(end_image)
   (start_image "Slide6")(slide_image 1 1 X# Y# (strcat Folder$ Slide6$))(end_image)
   (start_image "Slide7")(slide_image 1 1 X# Y# (strcat Folder$ Slide7$))(end_image)
   (start_image "Slide8")(slide_image 1 1 X# Y# (strcat Folder$ Slide8$))(end_image)
   (start_image "Slide9")(slide_image 1 1 X# Y# (strcat Folder$ Slide9$))(end_image)
   (start_image "Slide10")(slide_image 1 1 X# Y# (strcat Folder$ Slide10$))(end_image)
   (start_image "Slide11")(slide_image 1 1 X# Y# (strcat Folder$ Slide11$))(end_image)
   (start_image "Slide12")(slide_image 1 1 X# Y# (strcat Folder$ Slide12$))(end_image)
   (start_image "Slide13")(slide_image 1 1 X# Y# (strcat Folder$ Slide13$))(end_image)
   (start_image "Slide14")(slide_image 1 1 X# Y# (strcat Folder$ Slide14$))(end_image)
   (start_image "Slide15")(slide_image 1 1 X# Y# (strcat Folder$ Slide15$))(end_image)
   (start_image "Slide16")(slide_image 1 1 X# Y# (strcat Folder$ Slide16$))(end_image)

     ; Dialog Actions
	(action_tile "Slide1" "(done_dialog 11)")
	(action_tile "Slide2" "(done_dialog 12)")
	(action_tile "Slide3" "(done_dialog 13)")
	(action_tile "Slide4" "(done_dialog 14)")
	(action_tile "Slide5" "(done_dialog 15)")
	(action_tile "Slide6" "(done_dialog 16)")
	(action_tile "Slide7" "(done_dialog 17)")
	(action_tile "Slide8" "(done_dialog 18)")
	(action_tile "Slide9" "(done_dialog 19)")
	(action_tile "Slide10" "(done_dialog 20)")
	(action_tile "Slide11" "(done_dialog 21)")
	(action_tile "Slide12" "(done_dialog 22)")
	(action_tile "Slide13" "(done_dialog 23)")
	(action_tile "Slide14" "(done_dialog 24)")
	(action_tile "Slide15" "(done_dialog 25)")
	(action_tile "Slide16" "(done_dialog 26)")
	(action_tile "cancel" "(done_dialog 0)")
  
(setq a1 (start_dialog))
(setq osm (getvar "osmode"))
(command "attreq" "0")

(if (and a1 (> a1 1))
 (progn
	(command "snap" "0.0625")
(if (/= 16384 (logand 16384 (getvar "osmode")))						;set osmode
(setvar "osmode" (boole 6 (getvar "osmode") 16384))					;set osmode
)											;if
(setvar "osmode" 0)									;set osmode

                        (if (not (tblsearch "layer" "Pid"))
                            (entmake
                               (list
                                  (cons 0 "Layer")
                                  (cons 100 "AcDbSymbolTableRecord")
                                  (cons 100 "AcDbLayerTableRecord") 
                                  (cons 2 "Pid")
                                  (cons 70 0)
                                  (cons 62 4)
                                  (cons 6 "Continuous")
                                );list
                               );entmake
                          );if

(setvar "clayer" "Pid") 
(if (setq insertpt1 (getpoint "\nPick Insertion Point: "))
(progn
  (if (and (setq name (car (nentselp insertpt1)))
	   (wcmatch (cdr (assoc 0 (entget name)))"LINE,LWPOLYLINE")
	   );; and
    (setq objx 1)
    );; if
      (cond	
	((= a1 11)(MySub "ANGLE VALVE" 0.1250 -0.000001 insertpt1))					;a1 11
	((= a1 12)(MySub "BALL VALVE WITH BLEED VALVE" 0.1250 -0.1250 insertpt1))			;a1 12
	((= a1 13)(MySub "BALL VALVE" 0.1250 -0.1250 insertpt1))					;a1 13
	((= a1 14)(MySub "BUTTERFLY VALVE" 0.1250 -0.1250 insertpt1))					;a1 14
	((= a1 15)(MySub "CHECK VALVE" 0.1250 -0.1250 insertpt1))					;a1 15
	((= a1 16)(MySub "BUTTERFLY ON-OFF VALVE" 0.1250 -0.1250 insertpt1))				;a1 16
	((= a1 17)(MySub "DIAPHRAGM VALVE" 0.1250 -0.1250 insertpt1))					;a1 17
	((= a1 18)(MySub "GATE VALVE WITH BLEED VALVE" 0.1250 -0.1250 insertpt1))			;a1 18
	((= a1 19)(MySub "GATE VALVE" 0.1250 -0.1250 insertpt1))					;a1 19
	((= a1 20)(MySub "GLOBE VALVE" 0.1250 -0.1250 insertpt1))					;a1 20
	((= a1 21)(MySub "NEEDLE VALVE" 0.1250 -0.1250 insertpt1))					;a1 21
	((= a1 22)(MySub "PLUG VALVE" 0.1250 -0.1250 insertpt1))					;a1 22
	((= a1 23)(MySub "ROTARY VALVE" 0.1250 -0.1250 insertpt1))					;a1 23
	((= a1 24)(MySub "THREE-WAY VALVE" 0.1250 -0.1250 insertpt1))					;a1 24
	((= a1 25)(MySub "THREE-WAY BALL VALVE" 0.1250 -0.1250 insertpt1))				;a1 25
	((= a1 26)(MySub "FOUR-WAY VALVE" 0.1250 -0.1250 insertpt1))					;a1 26
       	)												;cond	
       )												;progn
	)												;a1 1 if
	))												;if progn test				
(setvar "osmode" osm)	
(setvar "cmdecho" 1)						
(princ)	
    (command "_.undo" "_end")									
)										

(defun MySub (a1 a2 a3 insertpt1 / OBJ P2 P3)						;subfunction
(vl-load-com)										;load vlisp functions
  (if (= objx 1)									;if flag is raised
    (progn										;do these actions
(setvar "osmode" 0)									;set osnap
(command "_insert" a1 insertpt1 "" "" pause)						;insert and select rotation
									
(if (> a2 0.0)										;if trim dist is greater than 0.0 preform
(progn
(setq obj (vlax-ename->vla-object name))
(if (eq (vla-get-ObjectName obj) "AcDbPolyline")					;; if it is a LwPolyline
     (setq p3 insertpt1
	   p2 (angle insertpt1  (vlax-curve-getpointatparam obj  (fix (vlax-curve-getparamatpoint obj insertpt1)))))		     
(setq p3 insertpt1
      p2 (angle (vlax-curve-getStartpoint obj) (vlax-curve-getEndPoint obj)))
)											;if
(command "break" name (polar p3 p2 a2) (polar p3 p2 a3))
)											;progn
(princ "\n......Selected....\n......Breaking Lines....")				;status
)											;if
)											;progn
(progn											;do these actions
  (command "_insert" a1 insertpt1 "" "" pause)						;insert				
  (princ)										;exit cleanly
)											;progn  
)											;if
(princ "\n......Insertion Completed!")							;print clear to screen
(princ)											;print clear

)											;MySub

 and the accompanying dcl

 

img : image_button
{
	height = 5.5;
	width = 18.00;
	fixed_width = true;
	fixed_height = true;
	alignment = centered;
	color = -2;
}
txt : text {fixed_width = true; alignment = centered; }
col : column {fixed_width = true; width = 35; }

  //---------------------------------------------------------------------------------------------------------
 // Manually Operated Valves Dialog
//	Brandon Hull, Cynthia helms, special thanks to : Lee Mac, Scot65, HmSilva
//		L-Con, 2013
 //---------------------------------------------------------------------------------------------------------
  manualvalves : dialog {
   label = "MANUALLY OPERATED VALVES"; spacer;
	: row 
	{
	   : col
	   {
		: img { key = "Slide1"; } : txt { label = "Angle Valve"; } spacer_1;
		: img { key = "Slide2"; } : txt { label = "Ball Valve w Bleed Valve"; } spacer_1;
		: img { key = "Slide3"; } : txt { label = "Ball Valve"; } spacer_1;
		: img { key = "Slide4"; } : txt { label = "Butterfly Valve"; }
	   }
	   : col
	   {
		: img { key = "Slide5"; } : txt { label = "Check Valve"; } spacer_1;
		: img { key = "Slide6"; } : txt { label = "Butterfly On-Off Valve"; } spacer_1;
		: img { key = "Slide7"; } : txt { label = "Diaphragm Valve"; } spacer_1;
		: img { key = "Slide8"; } : txt { label = "Gate Valve w Bleed Valve"; } 
	   }
	   : col
	   {
		: img { key = "Slide9"; } : txt { label = "Gate Valve"; } spacer_1;
		: img { key = "Slide10"; } : txt { label = "Globe Valve"; } spacer_1;    
		: img { key = "Slide11"; } : txt { label = "Needle Valve"; } spacer_1;
		: img { key = "Slide12"; } : txt { label = "Plug Valve"; } 
	   }
	   : col
	   {
		: img { key = "Slide13"; } : txt { label = "Rotary Valve"; } spacer_1;
		: img { key = "Slide14"; } : txt { label = "Three-Way Valve"; } spacer_1;
		: img { key = "Slide15"; } : txt { label = "Three-Way Ball Valve"; } spacer_1;	
		: img { key = "Slide16"; } : txt { label = "Four-Way Valve"; }
	   }
	}
	spacer; cancel_button;     
}///manualvalves

 



@bhull1985 wrote:

Have fun adapting this for your own needs/blocks.

(defun c:manualvalves (/ Dcl_Id% Folder$ Slides@ Slide1$ Slide2$ Slide3$ Slide4$ Slide5$ Slide6$ Slide7$ Slide8$ Slide9$ Slide10$ Slide11$ Slide12$ Slide13$ Slide14$ Slide15$ Slide16$ X# Y# ss a1 a2 a3 p2 p3 insertpt1 osm *error*)




  (command "_.undo" "_begin")


 (defun *error* ( msg )
      (if osm (setvar 'OSMODE osm))
      (if snpm (setvar 'SNAPMODE snpm))
      (if snp (command "snap" snp))
      (if echo (setvar 'CMDECHO echo))

    (if (not (member msg '("Function cancelled" "quit / exit abort")))
        (princ (strcat "\nError: " msg))
    )
    (princ)
    (command "_.undo" "_end")
    )



   (princ "\n*************************************")(princ)
   (princ "\n********Manual Valves Dialog*********")(princ)
;   (princ "\n**********L-Con Engineering**********")(princ)
;   (princ "\n********B. Hull C. Helms 2013********")(princ)
   (princ "\n*************************************")(princ "\n")
    ; Set Default Variables
   (setq Slides@ (list nil "ANGLE VALVE" "BALL VALVE WITH BLEED VALVE" "BALL VALVE" "BUTTERFLY VALVE" "CHECK VALVE" "BUTTERFLY ON-OFF VALVE" "DIAPHRAGM VALVE" "GATE VALVE WITH BLEED VALVE" "GATE VALVE" "GLOBE VALVE" "NEEDLE VALVE" "PLUG VALVE" "ROTARY VALVE" "THREE-WAY VALVE" "THREE-WAY BALL VALVE" "FOUR-WAY VALVE")
         Slide1$ (nth 1 Slides@)
         Slide2$ (nth 2 Slides@)
         Slide3$ (nth 3 Slides@)
         Slide4$ (nth 4 Slides@)
         Slide5$ (nth 5 Slides@)
         Slide6$ (nth 6 Slides@)
         Slide7$ (nth 7 Slides@)
         Slide8$ (nth 8 Slides@)
         Slide9$ (nth 9 Slides@)
         Slide10$ (nth 10 Slides@)
         Slide11$ (nth 11 Slides@)
         Slide12$ (nth 12 Slides@)
         Slide13$ (nth 13 Slides@)
         Slide14$ (nth 14 Slides@)
         Slide15$ (nth 15 Slides@)
         Slide16$ (nth 16 Slides@)
         Folder$ ""
         Return$ ""
   );setq
    ; Load Dialog

   (setq Dcl_Id% (load_dialog "manualvalves.dcl"))

   (new_dialog "manualvalves" Dcl_Id%)

    ; Set Dialog Initial Settings
   (set_tile "Title" "MANUALLY OPERATED VALVES")
   (set_tile "ANGLE VALVE" Slide1$)
   (set_tile "BALL VALVE WITH BLEED VALVE" Slide2$)
   (set_tile "BALL VALVE" Slide3$)
   (set_tile "BUTTERFLY VALVE" Slide4$)
   (set_tile "CHECK VALVE" Slide5$)
   (set_tile "BUTTERFLY ON-OFF VALVE" Slide6$)
   (set_tile "DIAPHRAGM VALVE" Slide7$)
   (set_tile "GATE VALVE WITH BLEED VALVE" Slide8$)
   (set_tile "GATE VALVE" Slide9$)
   (set_tile "GLOBE VALVE" Slide10$)
   (set_tile "NEEDLE VALVE" Slide11$)
   (set_tile "PLUG VALVE" Slide12$)
   (set_tile "ROTARY VALVE" Slide13$)
   (set_tile "THREE-WAY VALVE" Slide14$)
   (set_tile "THREE-WAY BALL VALVE" Slide15$)
   (set_tile "FOUR-WAY VALVE" Slide16$)

    ; Adjust X# and Y# per image_buttom outline to fit slide_image
   (start_image "Slide1")
   (setq X# (- (dimx_tile "Slide1") 2))
   (setq Y# (- (dimy_tile "Slide1") 2))
   (end_image)
   (start_image "Slide1")(slide_image 1 1 X# Y# (strcat Folder$ Slide1$))(end_image)
   (start_image "Slide2")(slide_image 1 1 X# Y# (strcat Folder$ Slide2$))(end_image)
   (start_image "Slide3")(slide_image 1 1 X# Y# (strcat Folder$ Slide3$))(end_image)
   (start_image "Slide4")(slide_image 1 1 X# Y# (strcat Folder$ Slide4$))(end_image)
   (start_image "Slide5")(slide_image 1 1 X# Y# (strcat Folder$ Slide5$))(end_image)
   (start_image "Slide6")(slide_image 1 1 X# Y# (strcat Folder$ Slide6$))(end_image)
   (start_image "Slide7")(slide_image 1 1 X# Y# (strcat Folder$ Slide7$))(end_image)
   (start_image "Slide8")(slide_image 1 1 X# Y# (strcat Folder$ Slide8$))(end_image)
   (start_image "Slide9")(slide_image 1 1 X# Y# (strcat Folder$ Slide9$))(end_image)
   (start_image "Slide10")(slide_image 1 1 X# Y# (strcat Folder$ Slide10$))(end_image)
   (start_image "Slide11")(slide_image 1 1 X# Y# (strcat Folder$ Slide11$))(end_image)
   (start_image "Slide12")(slide_image 1 1 X# Y# (strcat Folder$ Slide12$))(end_image)
   (start_image "Slide13")(slide_image 1 1 X# Y# (strcat Folder$ Slide13$))(end_image)
   (start_image "Slide14")(slide_image 1 1 X# Y# (strcat Folder$ Slide14$))(end_image)
   (start_image "Slide15")(slide_image 1 1 X# Y# (strcat Folder$ Slide15$))(end_image)
   (start_image "Slide16")(slide_image 1 1 X# Y# (strcat Folder$ Slide16$))(end_image)

     ; Dialog Actions
	(action_tile "Slide1" "(done_dialog 11)")
	(action_tile "Slide2" "(done_dialog 12)")
	(action_tile "Slide3" "(done_dialog 13)")
	(action_tile "Slide4" "(done_dialog 14)")
	(action_tile "Slide5" "(done_dialog 15)")
	(action_tile "Slide6" "(done_dialog 16)")
	(action_tile "Slide7" "(done_dialog 17)")
	(action_tile "Slide8" "(done_dialog 18)")
	(action_tile "Slide9" "(done_dialog 19)")
	(action_tile "Slide10" "(done_dialog 20)")
	(action_tile "Slide11" "(done_dialog 21)")
	(action_tile "Slide12" "(done_dialog 22)")
	(action_tile "Slide13" "(done_dialog 23)")
	(action_tile "Slide14" "(done_dialog 24)")
	(action_tile "Slide15" "(done_dialog 25)")
	(action_tile "Slide16" "(done_dialog 26)")
	(action_tile "cancel" "(done_dialog 0)")
  
(setq a1 (start_dialog))
(setq osm (getvar "osmode"))
(command "attreq" "0")

(if (and a1 (> a1 1))
 (progn
	(command "snap" "0.0625")
(if (/= 16384 (logand 16384 (getvar "osmode")))						;set osmode
(setvar "osmode" (boole 6 (getvar "osmode") 16384))					;set osmode
)											;if
(setvar "osmode" 0)									;set osmode

                        (if (not (tblsearch "layer" "Pid"))
                            (entmake
                               (list
                                  (cons 0 "Layer")
                                  (cons 100 "AcDbSymbolTableRecord")
                                  (cons 100 "AcDbLayerTableRecord") 
                                  (cons 2 "Pid")
                                  (cons 70 0)
                                  (cons 62 4)
                                  (cons 6 "Continuous")
                                );list
                               );entmake
                          );if

(setvar "clayer" "Pid") 
(if (setq insertpt1 (getpoint "\nPick Insertion Point: "))
(progn
  (if (and (setq name (car (nentselp insertpt1)))
	   (wcmatch (cdr (assoc 0 (entget name)))"LINE,LWPOLYLINE")
	   );; and
    (setq objx 1)
    );; if
      (cond	
	((= a1 11)(MySub "ANGLE VALVE" 0.1250 -0.000001 insertpt1))					;a1 11
	((= a1 12)(MySub "BALL VALVE WITH BLEED VALVE" 0.1250 -0.1250 insertpt1))			;a1 12
	((= a1 13)(MySub "BALL VALVE" 0.1250 -0.1250 insertpt1))					;a1 13
	((= a1 14)(MySub "BUTTERFLY VALVE" 0.1250 -0.1250 insertpt1))					;a1 14
	((= a1 15)(MySub "CHECK VALVE" 0.1250 -0.1250 insertpt1))					;a1 15
	((= a1 16)(MySub "BUTTERFLY ON-OFF VALVE" 0.1250 -0.1250 insertpt1))				;a1 16
	((= a1 17)(MySub "DIAPHRAGM VALVE" 0.1250 -0.1250 insertpt1))					;a1 17
	((= a1 18)(MySub "GATE VALVE WITH BLEED VALVE" 0.1250 -0.1250 insertpt1))			;a1 18
	((= a1 19)(MySub "GATE VALVE" 0.1250 -0.1250 insertpt1))					;a1 19
	((= a1 20)(MySub "GLOBE VALVE" 0.1250 -0.1250 insertpt1))					;a1 20
	((= a1 21)(MySub "NEEDLE VALVE" 0.1250 -0.1250 insertpt1))					;a1 21
	((= a1 22)(MySub "PLUG VALVE" 0.1250 -0.1250 insertpt1))					;a1 22
	((= a1 23)(MySub "ROTARY VALVE" 0.1250 -0.1250 insertpt1))					;a1 23
	((= a1 24)(MySub "THREE-WAY VALVE" 0.1250 -0.1250 insertpt1))					;a1 24
	((= a1 25)(MySub "THREE-WAY BALL VALVE" 0.1250 -0.1250 insertpt1))				;a1 25
	((= a1 26)(MySub "FOUR-WAY VALVE" 0.1250 -0.1250 insertpt1))					;a1 26
       	)												;cond	
       )												;progn
	)												;a1 1 if
	))												;if progn test				
(setvar "osmode" osm)	
(setvar "cmdecho" 1)						
(princ)	
    (command "_.undo" "_end")									
)										

(defun MySub (a1 a2 a3 insertpt1 / OBJ P2 P3)						;subfunction
(vl-load-com)										;load vlisp functions
  (if (= objx 1)									;if flag is raised
    (progn										;do these actions
(setvar "osmode" 0)									;set osnap
(command "_insert" a1 insertpt1 "" "" pause)						;insert and select rotation
									
(if (> a2 0.0)										;if trim dist is greater than 0.0 preform
(progn
(setq obj (vlax-ename->vla-object name))
(if (eq (vla-get-ObjectName obj) "AcDbPolyline")					;; if it is a LwPolyline
     (setq p3 insertpt1
	   p2 (angle insertpt1  (vlax-curve-getpointatparam obj  (fix (vlax-curve-getparamatpoint obj insertpt1)))))		     
(setq p3 insertpt1
      p2 (angle (vlax-curve-getStartpoint obj) (vlax-curve-getEndPoint obj)))
)											;if
(command "break" name (polar p3 p2 a2) (polar p3 p2 a3))
)											;progn
(princ "\n......Selected....\n......Breaking Lines....")				;status
)											;if
)											;progn
(progn											;do these actions
  (command "_insert" a1 insertpt1 "" "" pause)						;insert				
  (princ)										;exit cleanly
)											;progn  
)											;if
(princ "\n......Insertion Completed!")							;print clear to screen
(princ)											;print clear

)											;MySub

 and the accompanying dcl

 

img : image_button
{
	height = 5.5;
	width = 18.00;
	fixed_width = true;
	fixed_height = true;
	alignment = centered;
	color = -2;
}
txt : text {fixed_width = true; alignment = centered; }
col : column {fixed_width = true; width = 35; }

  //---------------------------------------------------------------------------------------------------------
 // Manually Operated Valves Dialog
//	Brandon Hull, Cynthia helms, special thanks to : Lee Mac, Scot65, HmSilva
//		L-Con, 2013
 //---------------------------------------------------------------------------------------------------------
  manualvalves : dialog {
   label = "MANUALLY OPERATED VALVES"; spacer;
	: row 
	{
	   : col
	   {
		: img { key = "Slide1"; } : txt { label = "Angle Valve"; } spacer_1;
		: img { key = "Slide2"; } : txt { label = "Ball Valve w Bleed Valve"; } spacer_1;
		: img { key = "Slide3"; } : txt { label = "Ball Valve"; } spacer_1;
		: img { key = "Slide4"; } : txt { label = "Butterfly Valve"; }
	   }
	   : col
	   {
		: img { key = "Slide5"; } : txt { label = "Check Valve"; } spacer_1;
		: img { key = "Slide6"; } : txt { label = "Butterfly On-Off Valve"; } spacer_1;
		: img { key = "Slide7"; } : txt { label = "Diaphragm Valve"; } spacer_1;
		: img { key = "Slide8"; } : txt { label = "Gate Valve w Bleed Valve"; } 
	   }
	   : col
	   {
		: img { key = "Slide9"; } : txt { label = "Gate Valve"; } spacer_1;
		: img { key = "Slide10"; } : txt { label = "Globe Valve"; } spacer_1;    
		: img { key = "Slide11"; } : txt { label = "Needle Valve"; } spacer_1;
		: img { key = "Slide12"; } : txt { label = "Plug Valve"; } 
	   }
	   : col
	   {
		: img { key = "Slide13"; } : txt { label = "Rotary Valve"; } spacer_1;
		: img { key = "Slide14"; } : txt { label = "Three-Way Valve"; } spacer_1;
		: img { key = "Slide15"; } : txt { label = "Three-Way Ball Valve"; } spacer_1;	
		: img { key = "Slide16"; } : txt { label = "Four-Way Valve"; }
	   }
	}
	spacer; cancel_button;     
}///manualvalves

 


Thanks BHull1985 for the lsp. Now how do i go about loading it into AutoCAD? Unfortunately, I need a step by step instructions. Is this something you can help me with? Could you send me a private message?

 

Thanks,

Jorge

Message 5 of 8
Ptkicker
in reply to: JZelayaABS

Yes.. some help please for the step by step.. to how to put this working ... 🙂
Message 6 of 8
bhull1985
in reply to: Ptkicker

Ok guys, give me a few days.

I'll get a larger post or find an old one, and either post back here,

..or post a link here to the other thread, that will have a step by step.

Thank you for your patience

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 7 of 8
bhull1985
in reply to: bhull1985

There's this thread, and i'm aware it doesn't have a full step-by-step of how to get this running, it does contain many steps and many hints to more steps.

Regardless, I'll come back and do a complete one here soon.

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/custom-CUI-help-for-blocks-please/m-p...

 

message 4, specifically

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 8 of 8
bhull1985
in reply to: bhull1985

Alright,

so First is to create your CUI.

You will need to create your menu items starting with the toplevel menu selection, as shown in the linked thread my toplevel menu item is "PIDs".

From there I've created 8 sub-menus all within the menu "PIDs".

Each of these sub menus has a series of MENU COMMANDS to LOAD the relevant LISP files. You should not have created all of these yet, but each of them will be one copy of the routine I have posted. These routines are what you are linking and calling up by creating this essential CUI file.

They are vital to the program.

So create your menu structure, and link your "LOAD Flanged/regular Control/Manually operated Valves" each one to their own corresponding lisp file.

Once you have done that, you should create each of these lisp files in a directory that autocad can find. This means they must be within a file accessable through the saved file search path within your options in autocad. This will allow the CUI to quickly find and display these new autocad menus, once you have properly linked the CUI from LOAD command to LISP file.

 

So great, now you've taken care of that. All the lisp files are created and linked to autocad via the CUI editor.

You will have your blocks- this is the most tedious and time consuming part of the whole setup is to create your slide images of the blocks you are going to use. Do this by centering your block on the screen and simply typing MSLIDE.

The lisp file contains these slide names and uses them to link the DCL to the correct block- it's how you let the users know which block they are selecting. They're actually clicking on a SLIDE that you've created via MSLIDE, but then once they click, your code and the programs takes back over, and finds the corresponding block to insert.

 

HTH! More to come if any questions.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost