
! script name: vsolids.d/holesolid
! var_topic: Make a solid of revolution out of a tool shape at a hole

!A
!A NAME:
!A
!A 	Hole solid   variational
!A
!A DESCRIPTION:
!A
!A 	This script will make a solid of revolution out of a tool shape.
!A
!B INSTRUCTIONS:
!B
!B 	TOOL: Select the tool.
!B
!B 	PLACEMENT POINT ABS X,Y,Z: Enter the X,Y,Z coordinates of the center
!B 		point of the cylinder.  NOTE: See XYZ INPUT OPTIONS.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: hole tool solid")

DIM Destination$[256]
DIM Answer$[256]
DIM Tool_name$[256]
DIM Toolid$[256]
DIM Name$[256]
DIM Hole_name$[256]

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

ActivateUndo
Start:!
Stat=SetPickMask(WsPickHoles)
Stat=SetInputFormat("n0","")
Hs=PickEntity("PICK HOLE")
Stat=SetPickMask(WsPickALL)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Hs) THEN Pick_point
Stat= EntityNameCheck(Hs,Hole_name$)

Tool= GetAssocTool(Hs)
IF NOT ValidGeometry(Tool) THEN Start




Stat= GenerateVarName(WsRevolutionEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("REVOLUTION: Tool hole shape")
Stat= SetRecDelLastExec
H1= FindNamedEntity(Hole_name$)
P1= ParameterPt(H1,1.0)
P2= ParameterPt(H1,0.0)
Axis_line= LineTwoPoints(P1,P2)
Tool= GetAssocTool(H1)
Mdef1= ToolMillingDef(Tool,Mill_dir)
Stat=Setup3dCutter(Mdef1)
C1= CutterSolid(Axis_line,WsTrue)
Stat= NameEntity(C1,Name$)
Stat= DeleteEntityList(Mdef1,Axis_line,P1,P2)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(C1) THEN
           DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("hole shape")
	Stat= AddItemToUndo(WsUBCreateMode,C1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Start

Leave:!
Stat=SetPickMask(WsPickALL)
Stat= DeleteEntity(P1)
Stat= DeleteEntity(P2)
Stat= DeleteEntity(Axis_line)
Stat=SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	  LOAD "typecontrol"
ELSE
	  LOAD Destination$
END IF
END
