# By Axelerator AB All rights reserved
# Author Marcus Isaksson
from varmain .primitiv import *#line:5
from varmain .custom import *#line:6
from varmain .var_basic import *#line:7
from varmain .dummy_var import *#line:8
from aqa .math import *#line:9
import math #line:10
import sys ,os #line:11
if not os .path .dirname (os .path .abspath (__file__ ))in sys .path :#line:17
			   sys .path .append (os .path .dirname (os .path .abspath (__file__ )))#line:18
from AX_BOXF import *#line:21
@activate (Group ="Flange",TooltipShort ="Flange Alu EN-ISO",TooltipLong ="Flange Alu EN-ISO",LengthUnit ="mm",Ports ="2")#line:24
@group ("MainDimensions")#line:25
@param (DN =LENGTH ,TooltipShort ="Nominal Diameter",TooltipLong ="Nominal Diameter")#line:26
@param (TYP =LENGTH ,TooltipShort ="Flange Type",TooltipLong ="Flange Type Threaded / Non-Threaded")#line:27
@param (MATERIAL =LENGTH ,TooltipShort ="Alu or Steel",TooltipLong ="Alu or Steel")#line:30
def AX_P1_FLANGE_EN_ISO (O0O00O0OOOOOO0OOO ,DN =65 ,TYP =0 ,MATERIAL =0 ,**O0O000000O000OO0O ):#line:35
	if TYP ==0 :#line:37
		if DN ==65 :#line:38
			O0000OOOO00OOO0OO =63.0 #line:39
			O00O0O0O00OO0000O =185.0 #line:40
			O0O00OO0OO00OOOO0 =145.0 #line:41
			O000OO0OOOOO000O0 =18.0 #line:42
			O0OO0O00O0OOO0OOO =23.0 #line:43
			OO0000O000OO0OOOO =146.5 #line:44
		elif DN ==80 :#line:45
			O0000OOOO00OOO0OO =76.0 #line:46
			O00O0O0O00OO0000O =200.0 #line:47
			O0O00OO0OO00OOOO0 =160.0 #line:48
			O000OO0OOOOO000O0 =18.0 #line:49
			O0OO0O00O0OOO0OOO =24.6 #line:50
			OO0000O000OO0OOOO =106.8 #line:51
		elif DN ==100 :#line:52
			O0000OOOO00OOO0OO =100.0 #line:53
			O00O0O0O00OO0000O =220.0 #line:54
			O0O00OO0OO00OOOO0 =180.0 #line:55
			O000OO0OOOOO000O0 =18.0 #line:56
			O0OO0O00O0OOO0OOO =24.6 #line:57
			OO0000O000OO0OOOO =106.8 #line:58
		elif DN ==150 :#line:59
			O0000OOOO00OOO0OO =168.0 #line:60
			O00O0O0O00OO0000O =279.0 #line:61
			O0O00OO0OO00OOOO0 =240.0 #line:62
			O000OO0OOOOO000O0 =22.7 #line:63
			O0OO0O00O0OOO0OOO =25.4 #line:64
			OO0000O000OO0OOOO =127.4 #line:65
		elif DN ==200 :#line:66
			O0000OOOO00OOO0OO =168.0 #line:67
			O00O0O0O00OO0000O =340.0 #line:68
			O0O00OO0OO00OOOO0 =295.0 #line:69
			O000OO0OOOOO000O0 =22.0 #line:70
			O0OO0O00O0OOO0OOO =29.3 #line:71
			OO0000O000OO0OOOO =199.3 #line:72
	elif TYP ==1 :#line:73
		if DN ==80 :#line:74
			O0000OOOO00OOO0OO =87.88 #line:75
			O00O0O0O00OO0000O =200.0 #line:76
			O0O00OO0OO00OOOO0 =160.0 #line:77
			O000OO0OOOOO000O0 =18.0 #line:78
			O0OO0O00O0OOO0OOO =24.6 #line:79
			OO0000O000OO0OOOO =91.6 #line:80
		elif DN ==100 :#line:81
			O0000OOOO00OOO0OO =87.88 #line:82
			O00O0O0O00OO0000O =220.0 #line:83
			O0O00OO0OO00OOOO0 =180.0 #line:84
			O000OO0OOOOO000O0 =18.0 #line:85
			O0OO0O00O0OOO0OOO =24.6 #line:86
			OO0000O000OO0OOOO =91.6 #line:87
	O00O00000O00O0O00 =CYLINDER (O0O00O0OOOOOO0OOO ,R =O00O0O0O00OO0000O /2.0 ,H =O0OO0O00O0OOO0OOO ).rotateY (90 )#line:91
	O0O0O00O00O000000 =CYLINDER (O0O00O0OOOOOO0OOO ,R =O0000OOOO00OOO0OO /2.0 ,H =OO0000O000OO0OOOO ).rotateY (90 )#line:92
	O00OOO0OOO0O00O00 =CONE (O0O00O0OOOOOO0OOO ,R1 =(O0000OOOO00OOO0OO /2.0 )*1.2 ,R2 =O0000OOOO00OOO0OO /2.0 ,H =O0OO0O00O0OOO0OOO /2.0 ).rotateY (90 ).translate ((O0OO0O00O0OOO0OOO ,0 ,0 ))#line:93
	OO0O0OOOO0O0O00O0 =34.90 #line:95
	if DN >=80 :#line:96
		O0O00OO0OO00000O0 =TORUS (O0O00O0OOOOOO0OOO ,R1 =O0000OOOO00OOO0OO /2.0 -2.0 ,R2 =4.0 ).rotateY (90 ).translate ((OO0000O000OO0OOOO -OO0O0OOOO0O0O00O0 ,0 ,0 ))#line:97
		O0000O0O0OOO0OOOO =[O0O0O00O00O000000 ,O00OOO0OOO0O00O00 ,O0O00OO0OO00000O0 ]#line:99
	else :#line:100
		O0000O0O0OOO0OOOO =[O0O0O00O00O000000 ,O00OOO0OOO0O00O00 ]#line:101
	if TYP ==1 :#line:102
		O0O0O00OO000OO0O0 =CYLINDER (O0O00O0OOOOOO0OOO ,R =O0000OOOO00OOO0OO /2.0 -2.0 +4.0 ,H =OO0000O000OO0OOOO -OO0O0OOOO0O0O00O0 ).rotateY (90 )#line:103
		O0000O0O0OOO0OOOO .append (O0O0O00OO000OO0O0 )#line:104
	for OO0O0OOOO00OO0O00 in O0000O0O0OOO0OOOO :#line:106
		O00O00000O00O0O00 .uniteWith (OO0O0OOOO00OO0O00 )#line:107
		OO0O0OOOO00OO0O00 .erase ()#line:108
	OOOOOO0OOO0000OOO =math .degrees (((math .pi )*2.0 )/8 )#line:111
	O00O0000OO00O0OO0 =OOOOOO0OOO0000OOO /2 #line:112
	O00OO00000O00O0OO =0 #line:113
	O00OO0O00O0O0O00O =O00O0000OO00O0OO0 #line:114
	while (O00OO00000O00O0OO <8 ):#line:115
		OOO0O00O00000OO0O =CYLINDER (O0O00O0OOOOOO0OOO ,R =O000OO0OOOOO000O0 /2.0 ,H =O0OO0O00O0OOO0OOO ).rotateY (90 ).translate ((0 ,0 ,O0O00OO0OO00OOOO0 /2.0 )).rotateX (O00OO0O00O0O0O00O )#line:116
		O00O00000O00O0O00 .subtractFrom (OOO0O00O00000OO0O )#line:117
		OOO0O00O00000OO0O .erase ()#line:118
		O00OO0O00O0O0O00O =O00OO0O00O0O0O00O +OOOOOO0OOO0000OOO #line:119
		O00OO00000O00O0OO =O00OO00000O00O0OO +1 #line:120
	OO000O000O00OOOO0 =CYLINDER (O0O00O0OOOOOO0OOO ,R =(O0000OOOO00OOO0OO /2.0 )-2 ,H =OO0000O000OO0OOOO ).rotateY (90 )#line:123
	O00O00000O00O0O00 .subtractFrom (OO000O000O00OOOO0 )#line:124
	OO000O000O00OOOO0 .erase ()#line:125
	if TYP ==0 :#line:127
		O0O00O0OOOOOO0OOO .setPoint ((OO0000O000OO0OOOO ,0 ,0 ),(1 ,0 ,0 ))#line:128
		O0O00O0OOOOOO0OOO .setPoint ((0 ,0 ,0 ),(-1 ,0 ,0 ))#line:129
	elif TYP ==1 :#line:131
		O0O00O0OOOOOO0OOO .setPoint ((OO0000O000OO0OOOO -OO0O0OOOO0O0O00O0 ,0 ,0 ),(1 ,0 ,0 ))#line:132
		O0O00O0OOOOOO0OOO .setPoint ((0 ,0 ,0 ),(-1 ,0 ,0 ))#line:133
