Hi again
I have triede to clean it up a little. But....
1. I can't get an output from 'cond' of the PBHT. No matter what tube data I put in....what to do?
2. I there a way to make the user select the routine by depending what line in the the user want to sync data to? As you can see I have now called the routines CBT1, CBT2, CB3 and CBT4 depending what line they want to edit in block. But I would like to have the user to commando to use instead of four. attached the Block CBT.dwg
;;cbt - Insert cold bend table of tubes of 4 items of tubes.
;; It calculates the the relationship between RB / D0 to find criteria for Heat treament ect.
;;;;;--------------------
;;;;;--------Line 1------
;;;;;--------------------
(defun c:cbt1 ( /
A_ITEM A_DIM A_DIMCAL A_THX A_THXCAL A_BENDRADIUS A_INCONEL_LAYER A_TFR A_BENDRATIO A_PBHT)
;;questions for user input - line 1
(setvar "cmdecho" 0)
(setq A_ITEM (getreal "\nItem no, for line 1? : "))
(setq A_DIM (getreal "\nOutside, Diameter of tube, for line 1? [mm]: "))
(setq A_THX (getreal "\nThickness of tube, for line 1? [mm]: "))
(setq A_BENDRADIUS (getreal "\nBend radius to center of tube, for line 1? [mm]: "))
(setq A_INCONEL_LAYER (getreal "\nSurface treatment, Inconel, Overlay , for line 1? [mm]: "))
;;Calculations of line
;;calculation of do
(setq A_DIMCAL (+ A_DIM (* A_INCONEL_LAYER 2)))
;;calculation of et
(setq A_THXCAL (+ A_THX A_INCONEL_LAYER))
;;calculation of relationship between rb / d0
(setq A_BENDRATIO (/ A_BENDRADIUS (+ A_DIM (* A_INCONEL_LAYER 2))))
;;calculation of TFR
(Setq A_TFR (/(* A_DIMCAL A_DIMCAL) (* A_THXCAL A_BENDRADIUS)))
;;selection of PHBT according to tabel
(cond
(
(or
(and (> A_DIMCAL 142) (> A_BENDRATIO 2.5))
(and (<= A_DIMCAL 142)(> A_BENDRATIO 1.3))
)
(setq A_PBHT "No post-bend heat treatment required")
)
(
(or
(and (> A_DIMCAL 142) (<= A_BENDRATIO 2.5))
(and (<= A_DIMCAL 142) (<= A_BENDRATIO 1.3))
)
(setq A_PBHT "Stress relieve")
)
(
t
(setq A_PBHT "No PBHT required")
)
)
;;-------------------------
;;;;Sync data to block cbt
;;-------------------------
(foreach attribute (vlax-invoke (vlax-ename->vla-object (car (entsel "\nPick a block to put attributes into: "))) 'getattributes)
(if (member (read (vla-get-tagstring attribute)) '(A_ITEM A_DIMCAL A_THXCAL A_INCONEL_LAYER A_BENDRADIUS A_BENDRATIO A_TFR A_PBHT))
(vla-put-textstring attribute (rtos (vl-symbol-value (read (vla-get-tagstring attribute))) 2 2))
)
)
(setvar "cmdecho" 1)
(princ)
)
;;;;;--------------------
;;;;;--------Line 2------
;;;;;--------------------
(defun c:cbt2 ( /
B_ITEM B_DIM B_DIMCAL B_THX B_THXCAL B_BENDRADIUS B_INCONEL_LAYER B_TFR B_BENDRATIO B_PBHT)
;;questions for user input - line 2
(setvar "cmdecho" 0)
(setq B_ITEM (getreal "\nItem no, for line 2? : "))
(setq B_DIM (getreal "\nOutside, Diameter of tube, for line 2? [mm]: "))
(setq B_THX (getreal "\nThickness of tube, for line 2? [mm]: "))
(setq B_BENDRADIUS (getreal "\nBend radius to center of tube, for line 2? [mm]: "))
(setq B_INCONEL_LAYER (getreal "\nSurface treatment, Inconel, Overlay , for line 2? [mm]: "))
;;Calculations of line
;;calculation of do
(setq B_DIMCAL (+ B_DIM (* B_INCONEL_LAYER 2)))
;;calculation of et
(setq B_THXCAL (+ B_THX B_INCONEL_LAYER))
;;calculation of relationship between rb / d0
(setq B_BENDRATIO (/ B_BENDRADIUS (+ B_DIM (* B_INCONEL_LAYER 2))))
;;calculation of TFR
(Setq B_TFR (/(* B_DIMCAL B_DIMCAL) (* B_THXCAL B_BENDRADIUS)))
;;selection of PHBT according to tabel
(cond
(
(or
(and (> B_DIMCAL 142) (> B_BENDRATIO 2.5))
(and (<= B_DIMCAL 142)(> B_BENDRATIO 1.3))
)
(setq B_PBHT "No post-bend heat treatment required")
)
(
(or
(and (> B_DIMCAL 142) (<= B_BENDRATIO 2.5))
(and (<= B_DIMCAL 142) (<= B_BENDRATIO 1.3))
)
(setq B_PBHT "Stress relieve")
)
(
t
(setq B_PBHT "No PBHT required")
)
)
;;-------------------------
;;;;Sync data to block cbt
;;-------------------------
(foreach attribute (vlax-invoke (vlax-ename->vla-object (car (entsel "\nPick a block to put attributes into: "))) 'getattributes)
(if (member (read (vla-get-tagstring attribute)) '(B_ITEM B_DIMCAL B_THXCAL B_INCONEL_LAYER B_BENDRADIUS B_BENDRATIO B_TFR B_PBHT))
(vla-put-textstring attribute (rtos (vl-symbol-value (read (vla-get-tagstring attribute))) 2 2))
)
)
(setvar "cmdecho" 1)
(princ)
)
;;;;;--------------------
;;;;;--------Line 3------
;;;;;--------------------
;;Variables
(defun c:cbt3 ( /
C_ITEM C_DIM C_DIMCAL C_THX C_THXCAL C_BENDRADIUS C_INCONEL_LAYER C_TFR C_BENDRATIO C_PBHT)
;;questions for user input line 3
(setvar "cmdecho" 0)
(setq C_ITEM (getreal "\nItem no, for line 3? : "))
(setq C_DIM (getreal "\nOutside, Diameter of tube, for line 3? [mm]: "))
(setq C_THX (getreal "\nThickness of tube, for line 3? [mm]: "))
(setq C_BENDRADIUS (getreal "\nBend radius to center of tube, for line 3? [mm]: "))
(setq C_INCONEL_LAYER (getreal "\nSurface treatment, Inconel, Overlay , for line 3? [mm]: "))
;;Calculations of line
;;calculation of do
(setq C_DIMCAL (+ C_DIM (* C_INCONEL_LAYER 2)))
;;calculation of et
(setq C_THXCAL (+ C_THX C_INCONEL_LAYER))
;;calculation of relationship between rb / d0
(setq C_BENDRATIO (/ C_BENDRADIUS (+ C_DIM (* C_INCONEL_LAYER 2))))
;;calculation of TFR
(Setq C_TFR (/(* C_DIMCAL C_DIMCAL) (* C_THXCAL C_BENDRADIUS)))
;;selection of PHBT according to tabel
(cond
(
(or
(and (> C_DIMCAL 142) (> C_BENDRATIO 2.5))
(and (<= C_DIMCAL 142)(> C_BENDRATIO 1.3))
)
(setq C_PBHT "No post-bend heat treatment required")
)
(
(or
(and (> C_DIMCAL 142) (<= C_BENDRATIO 2.5))
(and (<= C_DIMCAL 142) (<= C_BENDRATIO 1.3))
)
(setq C_PBHT "Stress relieve")
)
(
t
(setq C_PBHT "No PBHT required")
)
)
;;-------------------------
;;;;Sync data to block cbt
;;-------------------------
(foreach attribute (vlax-invoke (vlax-ename->vla-object (car (entsel "\nPick a block to put attributes into: "))) 'getattributes)
(if (member (read (vla-get-tagstring attribute)) '(C_ITEM C_DIMCAL C_THXCAL C_INCONEL_LAYER C_BENDRADIUS C_BENDRATIO C_TFR C_PBHT))
(vla-put-textstring attribute (rtos (vl-symbol-value (read (vla-get-tagstring attribute))) 2 2))
)
)
(setvar "cmdecho" 1)
(princ)
)
;;;;;--------------------
;;;;;--------Line 4------
;;;;;--------------------
;;Variables
(defun c:cbt4 ( /
D_ITEM D_DIM D_DIMCAL D_THX D_THXCAL D_BENDRADIUS D_INCONEL_LAYER D_TFR D_BENDRATIO D_PBHT)
;;questions for user input line 4
(setvar "cmdecho" 0)
(setq D_ITEM (getreal "\nItem no, for line 4? : "))
(setq D_DIM (getreal "\nOutside, Diameter of tube, for line 4? [mm]: "))
(setq D_THX (getreal "\nThickness of tube, for line 4? [mm]: "))
(setq D_BENDRADIUS (getreal "\nBend radius to center of tube, for line 4? [mm]: "))
(setq D_INCONEL_LAYER (getreal "\nSurface treatment, Inconel, Overlay , for line ¤? [mm]: "))
;;Calculations of line
;;calculation of do
(setq D_DIMCAL (+ D_DIM (* D_INCONEL_LAYER 2)))
;;calculation of et
(setq D_THXCAL (+ D_THX D_INCONEL_LAYER))
;;calculation of relationship between rb / d0
(setq D_BENDRATIO (/ D_BENDRADIUS (+ D_DIM (* D_INCONEL_LAYER 2))))
;;calculation of TFR
(Setq D_TFR (/(* D_DIMCAL D_DIMCAL) (* D_THXCAL D_BENDRADIUS)))
;;selection of PHBT according to tabel
(cond
(
(or
(and (> D_DIMCAL 142) (> D_BENDRATIO 2.5))
(and (<= D_DIMCAL 142)(> D_BENDRATIO 1.3))
)
(setq D_PBHT "No post-bend heat treatment required")
)
(
(or
(and (> D_DIMCAL 142) (<= D_BENDRATIO 2.5))
(and (<= D_DIMCAL 142) (<= D_BENDRATIO 1.3))
)
(setq D_PBHT "Stress relieve")
)
(
t
(setq D_PBHT "No PBHT required")
)
)
;;-------------------------
;;;;Sync data to block cbt
;;-------------------------
(foreach attribute (vlax-invoke (vlax-ename->vla-object (car (entsel "\nPick a block to put attributes into: "))) 'getattributes)
(if (member (read (vla-get-tagstring attribute)) '(D_ITEM D_DIMCAL D_THXCAL D_INCONEL_LAYER D_BENDRADIUS D_BENDRATIO D_TFR D_PBHT))
(vla-put-textstring attribute (rtos (vl-symbol-value (read (vla-get-tagstring attribute))) 2 2))
)
)
(setvar "cmdecho" 1)
(princ)
)