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

!A
!A NAME:
!A
!A 	name
!A
!A DESCRIPTION:
!A
!A 	NO HELP AVAILABLE AT THIS TIME
!A
!B INSTRUCTIONS:
!B
!B 	questions with brief description
!B
!B OPTIONS:
!B 	
!B
stat=ChangeLabelStr("ScriptNameStatus","Function: make hole feature ")

DIM Answer$[256],Destination$[256]
DIM Title$[256],Label$[256]
DIM Namelist$[5000],Name$[256],Feat_name$[256]
DIM Question$[256]

DeActivateUndo
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 ValidGeometry(Mdef) THEN Start

PRINT GetMachDefValue(Mdef,WsFinishDepth)
! TO DO:  FIND or CREATE the feature

Do_feature: Angle= 0
PlotOff
Pref=  PointXYZ(0,0,0)
Pdest= PointXYZ(0,0,0)
Paxis= PointXYZ(0,0,1)
Axis_line= LineTwoPoints(Pref,Paxis)
Stat= MakeInvisible(Pref)
Stat= MakeInvisible(Pdest)
Stat= MakeInvisible(Paxis)
Stat= MakeInvisible(Axis_line)

Group= FeatureCircles(Mdef,0)
PlotOn

New_group:PlotOff
Vnum= LastPickView
Stat=SetInputFormat("n4b","")
Group1= CopyEntity(Group)
Stat= StripNonGeometry(Group1,WsFalse)

Place_min= NamedVarVal("Graph place min",WsSystemVars,50)
Place_max= NamedVarVal("Graph place max",WsSystemVars,500)
Place_density= NamedVarVal("Graph place density",WsSystemVars,3)
PlotOn
Group2= MakeSparseGroup(Group1,Place_min,Place_max,Place_density)

IF NOT ValidGeometry(Group2) THEN
	Group2= Group1
ELSE
	IF NOT GroupCount(Group2) THEN Group2= Group1
END IF

Stat=SetPickMask(WsPickNoSurf)
Stat= MakeInvisible(Group)
Rotate_angle= DynamicMoveGroup(Vnum,Group2,Pref,Pdest,Angle,"PICK DESTINATION POINT")
Stat= DeleteEntity(Group1)
Stat= DeleteEntity(Group2)
IF ExitScript(Destination$) THEN
	Stat= DeleteGroup(Group,1)
	Stat= DeleteEntity(Pm)
	Stat= DeleteEntity(Pref)
	Stat= DeleteEntity(Pdest)
	Stat= DeleteEntity(Paxis)
	Stat= DeleteEntity(Axis_line)

	IF Destination$= "SCRIPTSTART" OR Destination$= "BACKUP" THEN
		GOTO Start
	ELSE
		GOTO Leave
	END IF
END IF

Stat=XYZPointValues(Pref,Xs,Ys,Zs)
Stat=XYZPointValues(Pdest,Xe,Ye,Ze)

Xmove=Xe-Xs
Ymove=Ye-Ys
Zmove=Ze-Zs
Pm=PointXYZ(Xmove,Ymove,Zmove)

Shift_trans=AngleTransform(Pm,0,0,0,WsWorkplaneVals)
Axis_trans= RotAboutAxisTrans(Axis_line,Rotate_angle)
Trans1=MultTransforms(Shift_trans,Axis_trans)
Stat=TransGroupTrans(Group,Trans1)
Stat= MakeVisible(Group)
Stat= PlotEntity(Group)
Stat= DeleteEntity(Group)
Stat= DeleteEntity(Pm)
Stat= DeleteEntity(Pref)
Stat= DeleteEntity(Pdest)
Stat= DeleteEntity(Paxis)
Stat= DeleteEntity(Axis_line)

Stat= SetInputFormat("n4","")
GOTO Do_feature

Leave:! 
LowerSelectBox
IF Destination$= "SCRIPTSTART" THEN Start
IF Destination$= "BACKUP" THEN Start
IF LEN(Destination$) THEN LOAD Destination$
LOAD "typecontrol"
END
