
! script name: parasolids.d/cliffedgeblend
! solids: create a cliff edge blend between two face groups

!A
!A NAME:
!A
!A 	Cliff Edge Face Blend
!A
!A DESCRIPTION:
!A
!A	This script creates a blend between two face groups. The group of
!A	edges which form the cliff edge, limit the extent of the blend. 	
!A
!A~ image location - images/pkcliffedgefaceblend.gif
!B INSTRUCTIONS:
!B
!B	RADIUS:   Input the radius of the blend.
!B	
!B	BLEND TRIM: None, Short, Long, To walls: Enter the blend trim method.
!B
!B		None:   The blend is not trimmed. 
!B		Short:  The blend is created as short as possible.
!B		Long:   The blend is created as long as possible.
!B		To walls: The blend is trimmed to be walls.(Default)
!B	
!B	WALL TRIM: None, Attach, Both, Walls solid: Enter the wall trim method.
!B
!B		None: The walls are not trimmed.
!B		Attach: The walls are trimmed and then the blend is attached
!B				to the walls.
!B		Both: The walls are trimmed. But not attached. Remain 
!B				separate sheet bodies.
!B		Walls solid. Same as attach, but if resulting sheet encloses
!B			a solid volume make into a solid.
!B
!B	LEFT WALL FACE GROUP: Select the faces on the left wall of the blend.
!B
!B	RIGHT WALL FACES GROUP: Select the faces on the	right wall of the blend.
!B
!B	PICK CLIFF EDGES GROUP: Select the group of edges forming the cliffedge.
!B
!C NOTE:
!C
!C	The face and edge groups are automatically unlinked after the blend
!C	is created.
!C
!C	One application of the cliffedge blend is to create a blend
!C	between a surface and a curve. The surface would be the group
!C	of faces, the curve the group of cliffedges.
!C
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: cliff edge  blend ")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]

ActivateUndo


Radius=NamedVarVal("solid blend radius",WsPKSolidsVars,0.0)
Stat= GLPlotOn
Start:!

Ask_radius:!
Stat=SetInputFormat("n4=","")
Stat=SetRadiusEquals(Radius)
Radius=InputRadius("RADIUS")
IF ExitScript(Destination$) THEN Leave

Blend_trim:!
Stat=SetInputFormat("a1=",",N,S,L,T,")
Stat= SetEqualsValue(0,"T")
Stat=GetValue("BLEND TRIM: None, Short, Long, To walls ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N"
	Blend_trim=0
CASE "T"
	Blend_trim=1
CASE "S"
	Blend_trim=2
CASE "L"
	Blend_trim=3
END SELECT

Wall_trim:!
Stat=SetInputFormat("a1=",",N,A,B,W,")
Stat= SetEqualsValue(0,"A")
Stat=GetValue("WALL TRIM: None, Attach, Both, Walls solid ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N"
	Blend_walls=0
CASE "A"
	Blend_walls=1
CASE "B"
	Blend_walls=2
CASE "W"
	Blend_walls=3
END SELECT

Pick_left:!
E1=WPKPickEntity("LEFT WALL FACE GROUP")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Start

Pkleftgrp= WPKContainingGroup(E1,1,2)
IF NOT WPKIsEntity(Pkleftgrp) THEN Pick_left

UVpoint=LastUVSurfPick(E1)
IF NOT ValidGeometry(UVpoint) THEN Pick_left
U=XPointValue(UVpoint)
V=YPointValue(UVpoint)
Stat= DeleteEntity(UVPoint)
Pt= SurfParameterPt(E1,U,V)

Pick_right:!
E1=WPKPickEntity("RIGHT WALL FACE GROUP")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Start

Pkrightgrp= WPKContainingGroup(E1,1,2)
IF NOT WPKIsEntity(Pkrightgrp) THEN Pick_right

Pick_cliff:!
Stat=SetInputFormat("a1=",",N,")
Stat= SetEqualsValue(0,"N")
E1=WPKPickEntity("PICK CLIFF EDGES GROUP",WsPKPickEdge,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="N" THEN
	Pkcliffgrp=0
ELSE
	IF NOT WPKIsEntity(E1) THEN Pick_entity
	Pkcliffgrp= WPKContainingGroup(E1)
	IF NOT WPKIsEntity(Pkcliffgrp) THEN Pick_cliff
END IF

Make_blend:!
WPKClearErrorFlag

Left_sense= WsFalse
Right_sense= WsFalse
Propagate= WsTrue

WPKClearErrorFlag
G1= WPKBlendFaceGrps(Radius,Pkleftgrp,Pkrightgrp,Left_sense,Right_sense,Pt,Propagate,Blend_trim,Blend_walls,Pkcliffgrp)
Stat= DeleteEntity(Pt)
Stat= DeleteEntity(G1)
IF Blend_walls<>0 THEN
Stat= WPKRemoveGroup(Pkleftgrp)
Stat= WPKRemoveGroup(Pkrightgrp)
Stat= WPKRemoveGroup(Pkcliffgrp)
END IF


ActivateUndo
Stat= AdvanceUndoNumber("cliff edge face blend")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Start


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