
! script name: 3dcpath.d/smoothcpathgrp
! 3dtopic: smooths a group of cutterpaths

!A
!A NAME:
!A
!A 	Smooth 3D Cutterpath Group	
!A
!A DESCRIPTION:
!A
!A 	This script wil smooth a group of 3D Cutterpaths.
!A
!B INSTRUCTIONS:
!B
!B 	PICK GROUP TO BE CHANGED: Pick the group path to be changed.
!B
!B
!C NOTES:
!C
!C	The smoothed curve will deviate from the original cutterpath.
!C	The deviation may be enough to cause gouging. There is no
!C	check for this in this function.
!C
!C	The free parameter Smooth will determine the method of smoothing
!C	A value of Smooth=1 will use a cubic nurb curve. A value of
!C	Smooth=2 will use a bezier curve.
!C
!C	The free parameter Distance will control the number of extra
!C	points generated for the nurb curves. A small distance will
!C	cause more points to be generated thus causing the smoothed
!C	curve to be closer to the contour.
!C
!C	The free parameter Output circles will cause the curve to
!C	be generated with circle and line segments.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: smooth 3d cutterpath group ")

DIM Destination$[256]
DIM Answer$[256]

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

DeActivateUndo
Tol=NamedVarVal("3D Cutting Tol",Ws3DSystemVars,0.005)
Dist=NamedVarVal("smoothing distance",WsSystemVars,100*Tol)
Circle_sw=1
Smooth= 1


Pick_loop:Group=PickGroupEnt("PICK GROUP OF CUTTERPATHS")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Group) THEN Pick_loop


Stat=EraseEntity(Group)
Stat=SmoothCpathGrp(Group$,Dist,Tol,Smooth,Circle_sw)
Stat=PlotEntity(Group)

GOTO Pick_loop

Leave:!
V1=CreateVariable("smoothing distance",WsSystemVars,Dist)
Stat=SetInputFormat("n4","")
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END

