
! script name: drawings.d/ makedrawing
! topic: Sample - make a drawing entity

!A
!A NAME:
!A
!A 	Make Drawing
!A
!A DESCRIPTION:
!A
!A 	This script makes a drawing entity.
!A
!B INSTRUCTIONS:
!B
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: make drawing ")

DIM Answer$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Layers$[256]
DIM Colors$[256]
DIM Model$[256]
DEG



DeActivateUndo
Draw_loop:! 
StdWorkplane

Num_drawings= EntityTypeCount(WsDrawingEnt)
Stat= SetEqualsValue(0,"Drawing "&VAL$(Num_drawings+1))
stat= SetInputFormat("a99=","")
stat= GetValue("DRAWING NAME ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Name$= Answer$

stat= SetInputFormat("n4a1",",A,B,C,D,E,")
Draw_len= GetValue("DRAWING LENGTH  A, B, C, D, E  ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "A"
	Draw_len= 12
	Draw_width= 9
	vlength= 3
	vwidth= 2
	vheight= 3
CASE "B"
	Draw_len= 18
	Draw_width= 12
	vlength= 4
	vwidth= 3
	vheight= 4
CASE "C"
	Draw_len= 24
	Draw_width= 18
	vlength= 6
	vwidth= 4
	vheight= 6
CASE "D"
	Draw_len= 36
	Draw_width= 24
	vlength= 8
	vwidth= 6
	vheight= 8
CASE "E"
	Draw_len= 48
	Draw_width= 36
	vlength= 10
	vwidth= 8
	vheight= 10

CASE ELSE

	stat= SetInputFormat("n4","")
	Draw_width= GetValue("DRAWING WIDTH ")
	IF (ExitScript(Destination$)) THEN Leave

	vlength= Draw_len/6
	vwidth= Draw_width/6
	vheight= Draw_len/6

END SELECT

View_points:!
	Xc= Draw_len/2
	Yc= Draw_width/2
	Xspace= 1
	Yspace= 1

X1= Xc- Vlength- Xspace
Y1= Yc- Vwidth- Yspace

X2= Xc- Vlength- Xspace
Y2= Yc+ Vwidth+ Yspace

X3= Xc+ Vlength+ Xspace
Y3= Yc+ Vwidth+ Yspace

X4= Xc+ Vlength+ Xspace
Y4= Yc- Vwidth- Yspace

Ptopview= PointXYZ(X2,Y2,0)
Pfrontview= PointXYZ(X1,Y1,0)
Psideview= PointXYZ(X3,Y3,0)
Pisoview= PointXYZ(X4,Y4,0)


Stat=SetInputFormat("a99",",A,N,",WsFalse)
Stat=GetValue("ASSOCIATED DRAWING LAYERS VISIBLE, All ",Layers$)
IF (ExitScript(Destination$)) THEN Leave
IF Layers$="CANCEL" THEN Leave
IF Layers$="A" OR Layers$="a" THEN Layers$=""
IF Layers$="All" OR Layers$="all" THEN Layers$=""
IF Layers$="N" OR Layers$="n" THEN Layers$=""
IF Layers$="None" OR Layers$="none" THEN Layers$=""
IF LEN(Layers$) THEN Layers$= ","&Layers$&","

Stat=SetInputFormat("a99",",A,N,",WsFalse)
Stat=GetValue("LAYERS VISIBLE ON ALL VIEWS, None ",Model$)
IF (ExitScript(Destination$)) THEN Leave
IF Layers$="CANCEL" THEN Leave
IF Model$="A" OR Model$="a" THEN Model$=""
IF Model$="All" OR Model$="all" THEN Model$=""
IF Model$="N" OR Model$="n" THEN Model$=""
IF Model$="None" OR Model$="none" THEN Model$=""
IF LEN(Model$) THEN Model$= ","&Model$&","


Pc= PointXYZ(0,0,0)
Drawing= CreateDrawing(Pc,WsLowerLeft,Draw_len,Draw_width,Layers$,Colors$)
Stat= NameEntity(Drawing,Name$)

Stat=SetInputFormat("a99",",A,N,",WsFalse)
Stat=GetValue("TOP VIEW LAYERS , All ,None, ",Layers$)
IF (ExitScript(Destination$)) THEN Leave
IF Layers$="CANCEL" THEN Leave
IF Layers$="A" OR Layers$="a" THEN Layers$=""
IF Layers$="All" OR Layers$="all" THEN Layers$=""
IF Layers$="N" OR Layers$="n" THEN Layers$=""
IF Layers$="None" OR Layers$="none" THEN Layers$=""
IF LEN(Layers$) THEN Layers$= ","&Layers$&","
Layers$= Layers$&Model$

Scale1= 1.0
Pref= PointXYZ(0,0,0)
T1= AngleTransform(Pc,0,0,0)
View1= MakeStoredView("TOP","",T1,-10,10,-10,10,-10,10)
stat= ChangeViewLayers(View1,Layers$)
Stat= AddViewToDrawing(Drawing,View1,Ptopview,Pref,Scale1,-vlength,vlength,-vwidth,vwidth,-vheight,vheight)
Stat=DeleteEntity(Pref)
Stat=DeleteEntity(T1)
Stat=DeleteEntity(View1)

Stat=SetInputFormat("a99",",A,N,",WsFalse)
Stat=GetValue("SIDE VIEW LAYERS VISIBLE, All, None ",Layers$)
IF (ExitScript(Destination$)) THEN Leave
IF Layers$="CANCEL" THEN Leave
IF Layers$="A" OR Layers$="a" THEN Layers$=""
IF Layers$="All" OR Layers$="all" THEN Layers$=""
IF Layers$="N" OR Layers$="n" THEN Layers$=""
IF Layers$="None" OR Layers$="none" THEN Layers$=""
IF LEN(Layers$) THEN Layers$= ","&Layers$&","
Layers$= Layers$&Model$


Scale1= 1.0
Pref= PointXYZ(0,0,0)
T1= AngleTransform(Pc,0,90,0)
View1= MakeStoredView("SIDE","",T1,-10,10,-10,10,-10,10)
stat= ChangeViewLayers(View1,Layers$)
Stat= AddViewToDrawing(Drawing,View1,Psideview,Pref,Scale1,-vlength,vlength,-vwidth,vwidth,-vheight,vheight)
Stat=DeleteEntity(Pref)
Stat=DeleteEntity(T1)
Stat=DeleteEntity(View1)

Stat=SetInputFormat("a99",",A,N,",WsFalse)
Stat=GetValue("FRONT VIEW LAYERS VISIBLE, All, None ",Layers$)
IF (ExitScript(Destination$)) THEN Leave
IF Layers$="CANCEL" THEN Leave
IF Layers$="A" OR Layers$="a" THEN Layers$=""
IF Layers$="All" OR Layers$="all" THEN Layers$=""
IF Layers$="N" OR Layers$="n" THEN Layers$=""
IF Layers$="None" OR Layers$="none" THEN Layers$=""
IF LEN(Layers$) THEN Layers$= ","&Layers$&","
Layers$= Layers$&Model$


Scale1= 1.0
Pref= PointXYZ(0,0,0)
T1= AngleTransform(Pc,-90,0,0)
View1= MakeStoredView("FRONT","",T1,-10,10,-10,10,-10,10)
stat= ChangeViewLayers(View1,Layers$)
Stat= AddViewToDrawing(Drawing,View1,Pfrontview,Pref,Scale1,-vlength,vlength,-vwidth,vwidth,-vheight,vheight)
Stat=DeleteEntity(Pref)
Stat=DeleteEntity(T1)
Stat=DeleteEntity(View1)

Stat=SetInputFormat("a99",",A,,N,",WsFalse)
Stat=GetValue("ISO VIEW LAYERS VISIBLE, All, None ",Layers$)
IF (ExitScript(Destination$)) THEN Leave
IF Layers$="CANCEL" THEN Leave
IF Layers$="A" OR Layers$="a" THEN Layers$=""
IF Layers$="All" OR Layers$="all" THEN Layers$=""
IF Layers$="N" OR Layers$="n" THEN Layers$=""
IF Layers$="None" OR Layers$="none" THEN Layers$=""
IF LEN(Layers$) THEN Layers$= ","&Layers$&","
Layers$= Layers$&Model$


Scale1= 1.0
Pref= PointXYZ(0,0,0)
T1= AngleTransform(Pc,60,0,30)
T2= InverseTrans(T1)
View1= MakeStoredView("ISO","",T2,-10,10,-10,10,-10,10)
stat= ChangeViewLayers(View1,Layers$)
Stat= AddViewToDrawing(Drawing,View1,Pisoview,Pref,Scale1,-vlength,vlength,-vwidth,vwidth,-vheight,vheight)
Stat=DeleteEntity(Pref)
Stat=DeleteEntity(T1)
Stat=DeleteEntity(T2)
Stat=DeleteEntity(View1)

Stat=DeleteEntity(Ptopview)
Stat=DeleteEntity(Pfrontview)
Stat=DeleteEntity(Psideview)
Stat=DeleteEntity(Pisoview)
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(Pt)

Stat= PlotDrawing(Drawing,1,WsTrue)
Stat= SetActiveDrawing(Drawing)

GOTO Draw_loop

Leave:!
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(Pt)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
