
! script name: vsurfaces.d/surfdensity
! var_topic: change plotting density of surface

!A
!A NAME:
!A
!A 	Surface Density
!A
!A DESCRIPTION:
!A
!A 	This script allows the plotting density of a surface to be changed.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE: Pick the surface to be changed.
!B
!B 	U SECTIONS PLOT DENSITY: Enter the plot density to be used for the
!B 		U sections.
!B
!B 	V SECTIONS PLOT DENSITY: Enter the plot density to be used for the
!B 		V sections.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: surface density ")

DIM Destination$[256]
DIM Answer$[256]
DIM Surface$[256]
DIM Name$[256]
DIM U_var$[256]
DIM V_var$[256]

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


ActivateUndo
Ask_Density:!
Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(.35)
Plotu=GetValue("U SECTIONS PLOT DENSITY",Answer$)
IF ExitScript(Destination$) THEN Leave
No_u_var= LastVariableInput(U_var$)

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(.35)
Plotv=GetValue("V SECTIONS PLOT DENSITY",Answer$)
IF ExitScript(Destination$) THEN Leave
No_v_var= LastVariableInput(V_var$)

Pick_surf:!
Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n4a1",",N,")
E1=PickEntity("PICK SURFACE,  New density ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "N" THEN Ask_density
IF NOT ValidDependency(E1) THEN Pick_surf
Stat= EntityNameCheck(E1,Surface$)
Stat=SetPickMask(WsPickAll)

Stat=SetPickMask(WsPickGeometry)

ActivateUndo
Stat= AdvanceUndoNumber("surface density")
Stat= AddItemToUndo(WsUBModifyMode,Surface$)

RecordFunctionOn
Stat= RecordDescr("DENSITY: Surface")
IF No_u_var THEN
        V1= FreeParameter("U_density",Plotu)
ELSE
        V1= FreeParameter("U_density",U_var$)
END IF
IF No_v_var THEN
        V2= FreeParameter("V_density",Plotv)
ELSE
        V2= FreeParameter("V_density",V_var$)
END IF
Stat=SurfPlotDensity(Surface$,V1,V2)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_surf

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