;;>>>>>>>>>>> Construction de gaines souples de traitement d'air en 2D
;; Romain CARDINEAU
;; VERSION 19
;;>>>>>>>>>>
)
;tan
)
;asinGA
;-1<=y<=1
;returns inverse sin in radians
;acos
;-1<=y<=1
;returns inverse cos in radians
;; Add a Line
;; Get the current color values
)
;; Set TrueColor to blue (R=0, G=101, B=204)
(defun cs:linegainesouple
(PO PF
) oMSp
)
)
;; 3-Point Arc - Lee Mac
;; Returns the Center, Start/End Angle and Radius of the
;; Arc defined by three supplied points.
(defun LM:3PArc
(p1 p2 p3
/ cn m1 m2 m11 m12 m21 m22 angledebutarc anglefinarc rayonarc
)
(cs:linegainesouple p1 p3)
m2 (mid p2 p3)
)
)
)
(if (LM:Clockwise
-p p1 p2 p3
) )
oMSp
rayonarc
angledebutarc
anglefinarc
)
)
)
)
(defun cs:arcvla
(cn rayonarc angledebutarc anglefinarc
) oMSp
rayonarc
angledebutarc
anglefinarc
)
)
;; Midpoint - Lee Mac
;; Returns the midpoint of two points
)
;; Clockwise-p - Lee Mac
;; Returns T if p1,p2,p3 are clockwise oriented
(defun LM:Clockwise
-p
( p1 p2 p3
) )
)
(defun Polylineentmake
(lst
)
)
(defun ARCpoly
(ptcentre pt1 inclinaison numsecteur nbsecteur anglesecteur
/ rayon
) alpha
(angle ptcentre pt1
) )
(setq beta
(atan (* (cos inclinaison
) (tan
(* anglesecteur numsecteur
)))))
(setq Longpoint
(/ (* rayon
(cos (* anglesecteur numsecteur
))) (cos beta
))) (setq PTn
(polar ptcentre
(+ alpha beta
) Longpoint
) numsecteur (+ numsecteur 1)
)
)
(Polylineentmake ptlist)
)
;; Intersections - Lee Mac
;; Returns a list of all points of intersection between two objects
;; for the given intersection mode.
;; ob1,ob2 - [vla] VLA-Objects
;; mod - [int] acextendoption enum of intersectwith method
(defun LM:intersections
( ob1 ob2 mod
/ lst rtn
) )
)
)
)
)
(defun CreerATTRIBUT
(ATTinsertionpoint ATTetiquette ATTprompt ATTvaleur
) ;;(cons 8 "0") ;;Calque
(cons 10 ATTinsertionpoint
) ;insertion point (cons 40 0.1) ;Text height (cons 70 1) ;mode 1:invisible )
)
)
(defun CreerBLOC
(selectionset BlockName InsertPoint
/ number BlocknameNUM en
)
(command "_.CHPROP" selectionset
"" "_LA" "0" "") ;;change le calque du jeu de selection
)
)
)
(command "BLOC" BlocknameNUM InsertPoint selectionset
"")
)
(command "INSERER" BlocknameNUM InsertPoint
"" "" "")
)
;;==========================
;; Saisie des éléments de construction
;;==========================
(defun c:gaineflex
(/ selectionset insertionpoint number Blockname FlexStart FlexEnd PlineEnt FlexDuct1 FlexDuct2 FlexDuct3 FlexDuct4
rayoncourburearc nbarc anglearc anglearctot iarc longarc01 longarc02 longarc01PK longarc02PK choixpiq episolation
clrR clrG clrB clrR01 clrG01 clrB01 clrR02 clrG02 clrB02 deltaclrR deltaclrG deltaclrB longueurGS PTC rayon angleDEB angleFIN)
(command "TYPELIGNE" "CHARGER" "HIDDEN8" "zwcad.lin" "") )
(if (= initgainesouple
nil) (while (= initgainesouple
nil) (setq initgainesouple
(getdist "\nDiametre de la gaine : < 0.125 > [m]")) (if (= initgainesouple
nil) (setq initgainesouple
0.125)) )
)
(if (= initgainesouple
nil) (setq initgainesouple Dfirst
) (setq Dfirst initgainesouple
) )
(if (= initgainesoupleISO
nil) (while (= initgainesoupleISO
nil) (setq initgainesoupleISO
(getdist "\nEpaisseur isolation : < 50 > [mm]")) (setq initgainesoupleISO
50) )
)
(if (= initgainesoupleISO
nil) (setq initgainesoupleISO DfirstISO
) (setq DfirstISO initgainesoupleISO
) )
(setq episolation DfirstISO
) (setq D
(+ D
(* 0.002 episolation
)))
(command "POLYLIGN" FlexStart
"LA" D D FlexEnd
"arc") )
;;(vlax-put-property (vlax-ename->vla-object (entlast)) 'Layer "0")
;;(vlax-put-property (vlax-ename->vla-object (entlast)) 'ConstantWidth 0)
;;(ssadd (entlast) selectionset)
;; calculer la longueur du chemin
;;(setq LCHEM (vlax-curve-getDistAtPoint CHEM (vlax-curve-getEndPoint CHEM)))
;;(vlax-invoke-method oColor 'SetRGB 90 90 90)
;;(vlax-put-property (vlax-ename->vla-object (entlast)) 'TrueColor oColor)
clrG 100
clrB 100
clrR01 20 ;;20
clrG01 20 ;;20
clrB01 20 ;;20
clrR02 210 ;;210
clrG02 210 ;;210
clrB02 210 ;;210
nbdegrade 0 ;;8
rayoncourburearc (* D 1.50)
)
(if (> rayoncourburearc
(* D
0.51)) (setq rayoncourburearc rayoncourburearc
) (setq rayoncourburearc
(* D
0.51)))
(setq choixpiq
"Plafond")
)
)
(setq choixpiq
"Plafond") )
)
;;(initget 2 "P M")
;;(setq choixpiq (getkword "\nPiquage/Mural/<Plafond> :"))
;;(if (or (equal choixpiq "M") (equal choixpiq "m"))
;;(setq choixpiq "Mural")
;;(setq choixpiq "Plafond")
;;)
(if (> LCHEM
(* rayoncourburearc
0.50)) (if (> LCHEM rayoncourburearc
) (setq rayoncourburearc rayoncourburearc
) (setq rayoncourburearc LCHEM
) )
)
)
(if (= choixpiq
"Plafond")
;;(command "HACHURES" "_P" "SOLID" "_S" "_L" "" "")
;;(vlax-put-property (vlax-ename->vla-object (entlast)) 'Layer "0")
;;(ssadd (entlast) selectionset)
;;(vla-update obj)
;; Get the current color values
;;(setq oColor (vlax-get-property obj 'TrueColor)
;;clrR (vlax-get-property oColor 'Red)
;;clrG (vlax-get-property oColor 'Green)
;;clrB (vlax-get-property oColor 'Blue)
;;)
(setq deltaclrR
(fix (+ clrR01
(* (- clrR02 clrR01
) (/ (* D
(cos (* (- nbdegrade i
) (/ pi
(* 2 nbdegrade
))))) D
))))) (setq deltaclrG
(fix (+ clrG01
(* (- clrG02 clrG01
) (/ (* D
(cos (* (- nbdegrade i
) (/ pi
(* 2 nbdegrade
))))) D
))))) (setq deltaclrB
(fix (+ clrB01
(* (- clrB02 clrB01
) (/ (* D
(cos (* (- nbdegrade i
) (/ pi
(* 2 nbdegrade
))))) D
))))) (cons 40 (/ (* D
(cos (* i
(/ pi
(* 2 nbdegrade
))))) 2)) )
)
)
)
)
(setq deltaclrR
(fix (+ clrR01
(* (- clrR02 clrR01
) (/ (* D
(cos (* (- nbdegrade i
) (/ pi
(* 2 nbdegrade
))))) D
))))) (setq deltaclrG
(fix (+ clrG01
(* (- clrG02 clrG01
) (/ (* D
(cos (* (- nbdegrade i
) (/ pi
(* 2 nbdegrade
))))) D
))))) (setq deltaclrB
(fix (+ clrB01
(* (- clrB02 clrB01
) (/ (* D
(cos (* (- nbdegrade i
) (/ pi
(* 2 nbdegrade
))))) D
))))) ;;(vlax-invoke-method FlexDuct3 'update)
)
(setq PAS
(+ (* 0.10 D
) 0.028))
;;============================ construction des polylignes parallèles au chemin ==========================
(if (= choixpiq
"Plafond")
)
)
;;======= Construction des lignes perpendiculaires au chemin ======
(while (<= PK
(- LCHEM
(if (= choixpiq
"Plafond") rayoncourburearc
0)))
;; déterminer le paramètre au pk courant
;; déterminer le point au pk courant
;; déterminer la dérivée première
;; déterminer le point qui construit la tangente à la courbe au point PT
;; déterminer les points perpendiculaires à PT à une distance D
(if (= PK
0) (setq Alisere
0 Dlisere
0) (setq Alisere
(* D
0.12) Dlisere
(* D
0.4)))
;; passer au pk suivant
;; tracer la ligne
P5
(polar PTM
(angle PTG PTD
) (+ Alisere Dlisere
)) )
(cs:linegainesouple PTG P4)
(cs:linegainesouple PTD P5)
)
;;=====================================================================================================================================================
;;=============================construction des arcs si gaine souple piquage plafonnier================================================================
;;=====================================================================================================================================================
(if (= choixpiq
"Plafond")
nbarc
(fix (/ (* pi rayoncourburearc
) (* 2 PAS
))) anglearc (/ (/ pi 2) nbarc) ;;en radians
iarc -1
)
anglearctot (* anglearc iarc)
)
(if (= (- nbarc
1) iarc
) (setq anglearctot
(/ pi
2))) (setq longarc01
(* rayoncourburearc
(sin anglearctot
)) longarc02
(* (+ rayoncourburearc D
) (sin anglearctot
)) longarc01PK (+ longarc01 PK)
longarc02PK (+ longarc02 PK)
)
(if (= (- nbarc
1) iarc
) (setq longarc01PK LCHEM longarc02PK
(+ D LCHEM
))) )
ptcentre (mid PTG PTD)
)
(if (>= longarc02PK LCHEM
) PTM
(polar PT
(angle PT PTDERIV
) (- longarc02PK LCHEM
)) )
)
)
(setq P1 PTG P2 PTM P3 PTD
)
()
m2 (mid P2 P3)
)
)
)
alpha4 (acos (/ Alisere rayonarc))
P4
(polar PTC
(+ alpha4 alpha3
) rayonarc
) alpha5 (acos (/ (+ Alisere Dlisere) rayonarc))
P5
(polar PTC
(+ alpha5 alpha3
) rayonarc
) alpha6
(angle PTC
(mid P5 P3
)) P6
(polar PTC alpha6 rayonarc
) )
(setq anglesecteur
(/ pi
21) numsecteur 0
nbsecteur 8
anglearctot (- (/ pi 2) anglearctot)
)
(ARCpoly ptcentre PTD anglearctot numsecteur nbsecteur anglesecteur)
nbsecteur 12
)
(ARCpoly ptcentre PTD anglearctot numsecteur nbsecteur anglesecteur)
)
)
)
)
)
)
;;=====================================================================================================================================================
;;============================= Définition des attributs et Construction du bloc gaine souple =========================================================
;;=====================================================================================================================================================
(setq longueurGS
(+ LCHEM
(* rayoncourburearc
(- (/ pi
2) 1)))) )
(setq D
(rtos (* 2000 (- D
(* 0.001 episolation
))) 2 0)) (setq episolation
(rtos episolation
2 0))
;;CreerATTRIBUT ( ATTinsertionpoint ATTetiquette ATTprompt ATTvaleur )
(CreerATTRIBUT FlexStart "DIAMETRE" "Diamètre:" D)
(CreerATTRIBUT FlexStart "LONGUEUR" "Longueur:" longueurGS)
(CreerATTRIBUT FlexStart "ISOLATION" "Isolation:" episolation)
;;CreerBLOC (selectionset BlockName InsertPoint)
(CreerBLOC selectionset "GAINE_SOUPLE" FlexStart )
)