
! script name: vfeatitems.d/faceworkplane
! var_topic: Face item workplane

!A
!A NAME:
!A
!A	Face item workplane		VARIATIONAL
!A
!A DESCRIPTION:
!A	
!A	This script sets the workplane based on the face item of
!A	a picked entity.
!A
!B INSTRUCTIONS:
!B
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: face item workplane ")

DIM Destination$[512]
DIM Answer$[512]
DIM Name$[512]
DIM Class_name$[512]
DIM Plane_class$[512]
DIM Face_name$[512]
DIM Element$[256]


Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave


Class_name$="Planar Face Item"
Plane_class$="Face Plane Property"

Start:!

Pick_entity:!
Stat= SetInputFormat("n4","")
E1=PickEntity("PICK ENTITY")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_entity
Stat= EntityNameCheck(E1,Element$)

RecordFunctionOn
Stat=RecordDescr("WORKPLANE: Face item workplane ")
V1= StringConstant(Class_name$)
V2= StringConstant(Plane_class$)
Face_item= EntityItemByClass(Element$,V1)
G1= ItemGroup(Face_item)
G2= GrpByPropClass(G1,V2)
E1= GroupElement(G2,1)
Stat= SetWorkplane(E1)
Stat= DeleteEntity(G1)
Stat= DeleteEntity(G2)
RecordFunctionOff
CloseVarRecord

GOTO Start

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