MATCH_INSUL_THICKNESS_AMEP_v2_01..........free

This function is written for Autocad MEP.

Command: MAI

Function works in style of standard MATCHPROP command 

but matches only Insulation thickness of Autocad MEP pipes, ducts or fittings leaving other properties unchanged. Program can be stopped by ESC. 

Command: i0

Sets insulation thickness of selected objest to 0mm (removes insulation)

 

 

Code:

;;; ================================================
;;;        MATCH_INSUL_THICKNESS_AMEP_v2_01.LSP     
;;;
;;;        Written by Andrzej Kalinowski,     www.autolisps.blogspot.com
;;;        v1.00 - 13.10.2016 - first release
;;;        v2.01 - 23.04.2022 - corrected quiting the "Objects selection" loop
;;;
;;;        Command: MAI - Function works in style of standard MATCHPROP command
;;;                        but matches only Insulation thickness of Autocad MEP pipes, ducts 
;;;                        or fittings leaving other properties unchanged. 
;;;
;;;        Command: i0 - Sets insulation thickness of selected objest to 0mm (removes insulation)
;;; ================================================
(vl-load-com)
(defun c:MAI (/ obj1 selset2 type1 insulTh entlist1 i1 currentobject1 gr1)
    ;-----------------------------------------
    ;selection of the first mep obj
    ;-----------------------------------------
    (setq obj1 nil)
    (setq gr1 1)
    (while (/= gr1 52)
        (setvar "ERRNO" 0);reset ERRNO to 0
        (prompt "\nSelect first MEP duct/pipe/fitting ")
        (setq obj1 (ssget "_+.:S") )
        (setq gr1 (getvar "ERRNO") )
        (if (= (getvar "ERRNO") 52) (exit))
        (if (= obj1 nil)
            (princ "\nWrong object")
            (if (> (sslength obj1) 1)   
                (progn
                    (setq obj1 nil)
                    (princ "\nSelect only one object")(princ)
                );progn         
                (progn ;else
                    (setq
                        obj1 (ssname obj1 0)
                        entlist1 (entget obj1)
                        type1 (cdr (assoc 0 entlist1) )
                    );setq
                    (if (member type1 (list "AECB_PIPEFITTING" "AECB_DUCTFITTING" "AECB_PIPE" "AECB_DUCTFLEX" "AECB_DUCT") )
                        (setq gr1 52)
                        (progn     (prompt "\nWrong object")    (setq obj1 nil) )
                    );if
                );progn else     
            );end if
        );end if
    );end while
    (setq obj1 (vlax-ename->vla-object obj1)    insulTh (vlax-get obj1 'InsulationThickness) )
    ;-----------------------------------------
    ;selection of the second mep obj
    ;-----------------------------------------
    (setq gr1 1)
    (while (/= gr1 52)
        (setvar "ERRNO" 0);reset ERRNO to 0
        (prompt "\nSelect second MEP duct/pipe/fitting ")
        (setq selset2 (ssget "_:S" ) )
        (setq gr1 (getvar "ERRNO") )
        (if (= (getvar "ERRNO") 52) (exit))
        (if (= selset2 nil)
            (princ "\nWrong object");then
            (progn ;then
                (repeat (setq i1 (sslength selset2) );else
                    (setq
                        currentobject1 (ssname selset2 (setq i1 (1- i1) ) )
                        entlist1 (entget currentobject1)
                        type1 (cdr (assoc 0 entlist1)  )
                        currentobject1 (vlax-ename->vla-object currentobject1)
                    );setq
                    (if (not (member type1 (list "AECB_PIPEFITTING" "AECB_DUCTFITTING" "AECB_PIPE" "AECB_DUCTFLEX" "AECB_DUCT") ) )
                        (ssdel (vlax-vla-object->ename currentobject1) selset2);then
                    ); if
                );repeat
                ;-----------------------------------------
                ;matching insulation thickness property
                ;-----------------------------------------
        		(repeat (setq i1 (sslength selset2) )
                     (setq
                          currentobject1 (ssname selset2 (setq i1 (1- i1) ) )
                          currentobject1 (vlax-ename->vla-object currentobject1)
                     );setq
            	    (vlax-put currentobject1 'InsulationThickness insulTh)
        		);repeat	
            );progn	   
        );end if

	);while
);end defun
;;; ================================================
;                     INSULATION 0mm
;;; ================================================
(defun c:I0 (/ obj1 selset2 type1 insulTh entlist1 i1 currentobject1 gr1)	
    (setq insulTh 0)
    (setq obj1 nil)
    (setq gr1 1)
    ;-----------------------------------------
    ;selection of the second mep obj
    ;-----------------------------------------
    (while (/= gr1 52)
        (setvar "ERRNO" 0);reset ERRNO to 0
        (prompt "\nSelect second MEP duct/pipe/fitting ")
        (setq selset2 (ssget "_:S" ) )
        (setq gr1 (getvar "ERRNO") )
        (if (= (getvar "ERRNO") 52) (exit))
        (if (= selset2 nil)
            (princ "\nWrong object");then
            (progn ;then
                (repeat (setq i1 (sslength selset2) );else
                    (setq
                        currentobject1 (ssname selset2 (setq i1 (1- i1) ) )
                        entlist1 (entget currentobject1)
                        type1 (cdr (assoc 0 entlist1)  )
                        currentobject1 (vlax-ename->vla-object currentobject1)
                    );setq
                    (if (not (member type1 (list "AECB_PIPEFITTING" "AECB_DUCTFITTING" "AECB_PIPE" "AECB_DUCTFLEX" "AECB_DUCT") ) )
                        (ssdel (vlax-vla-object->ename currentobject1) selset2);then
                    );end if
                );repeat
                ;-----------------------------------------
                ;matching insulation thickness property
                ;-----------------------------------------
        		(repeat (setq i1 (sslength selset2) )
                     (setq
                          currentobject1 (ssname selset2 (setq i1 (1- i1) ) )
                          currentobject1 (vlax-ename->vla-object currentobject1)
                     );setq
            	    (vlax-put currentobject1 'InsulationThickness insulTh)
        		);repeat	
            );progn	   
        );end if

	);while
);end defun

Example:

Version history:
v1.00 - 13.10.2016 - first release
v2.01 - 23.04.2022 - corrected quiting the "Objects selection" loop


File format:
.FAS


Compatibility:
-All Autocad MEP
versions

 
Download file: MATCH_INSUL_THICKNESS_AMEP_v2_01.FAS

No comments:

Post a Comment