
! script name: holefeature.d/vdraftprofile
! topic: hole feature definition

!A
!A NAME:
!A
!A 	Profile
!A
!A DESCRIPTION:
!A
stat=ChangeLabelStr("ScriptNameStatus","Function: make hole feature ")

DIM Answer$[256],Destination$[256]
DIM Title$[256],Label$[256],Descr$[256]
DIM Namelist$[5000],Name$[256],Feat_name$[256]
DIM Question$[256],Angle_var$[256],Center$[256],Mdef_name$[256]

DeActivateUndo
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

Start:!
! TO DO:  Bring UP box with all FEATURES

Stat=UserSelectBox("HOLE FEATURES","selected feature",WsHoleFeatureDef,WsFeatureSelect)
IF Stat THEN Leave
Stat=SetInputFormat("a99","")
Stat=GetValue("FEATURE NAME ",Feat_name$)
IF ExitScript(Destination$) THEN Leave
IF Feat_name$= "CANCEL" THEN Leave
LowerSelectBox

Mdef= FindMachiningDef(Feat_name$,WsHoleFeatureDef)
IF NOT ValidDependency(Mdef) THEN Start

Angle_ques:Angle=InputAngle("ANGLE")
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)
L1= LastPickEnt
IF ValidGeometry(L1) THEN
        IF NOT ValidDependency(L1) THEN Angle_ques
        Stat= EntityNameCheck(L1,Angle_var$)
        No_angle_var=0
END IF

Point_loop:Stat=SetInputFormat("n4","")
E1=PickEntity("PICK POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Point_loop
Stat= EntityNameCheck(E1,Center$)
T= LastPickPara
Pick_return= CurrPickReturn

! TO DO:  FIND or CREATE the feature
Do_feature:!
Stat= EntityNameCheck(Mdef,Mdef_name$)
Descr$="FEATURE PROFILE: Draw feature profile"
Stat=GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr(Descr$)
SELECT Pick_return
CASE WsGeometryEnd
        Pc= ParameterReturnPt(Center$,T,WsGeometryEnd)
CASE WsGeometryMid
        Pc= ParameterReturnPt(Center$,T,WsGeometryMid)
CASE WsGeomCenter
        Pc= ParameterReturnPt(Center$,T,WsGeomCenter)
END SELECT
IF No_angle_var THEN
        V1= FreeParameter("Rotation_angle",Angle)
ELSE
        V1= FreeParameter("Rotation_angle",Angle_var$)
END IF
PlotOff
V2= FreeParameter("Chamfer on",0)
Group= FeatureProfile(Pc,Mdef_name$,V2)
T1=AngleTransform(Pc,90,0,V1,WsWorkplaneVals)
T2=InvertInPlane(T1)
G1=PlaneRotateGroup(Group,Pc,V1)
G2=TransformGroup(G1,T2,"TEMP1")
Stat=CombineGroups(G1,G2)
Stat=DeleteGroup(Group)
Stat=DeleteEntity(G2)
Stat=DeleteEntity(T2)
PlotOn
Stat=AutoNameGroup(G1,Name$)
Stat= SetNoPathFlag(G1,WsTrue)
Stat=DeleteEntity(Pc)
RecordFunctionOff

Stat=PlotEntity(G1)
RecordFunctionOn

Stat=DeleteEntity(G1)
RecordFunctionOff
CloseVarRecord

GOTO Point_loop

Leave:! 
LowerSelectBox
IF LEN(Destination$) THEN LOAD Destination$
LOAD "typecontrol"
END
