
! script name: vpksolids.d/vpkdoubleholdline
! var_solids: create a double holdline blend between two face groups

!A
!A NAME:
!A
!A 	Double Holdline Face Blend  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	This script creates a double holdline blend between two face groups.
!A	The blend is created tangent to the two face groups holding the
!A	edges of the blend along the holdlines. The blend will have a 
!A	variable conic cross-section. The blend cannot change its convexity
!A	as it propagates along the holdlines.
!A
!A~ image location - images/pkdoubleholdlineblend.gif
!B INSTRUCTIONS:
!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	FIRST HOLDLINE EDGES GROUP: Select the group of edges forming the 
!B					first holdline curve.
!B
!B	SECOND HOLDLINE EDGES GROUP: Select the group of edges forming the 
!B					second holdline curve.
!B
!C NOTE:
!C
!C	The face and edges groups are automatically deleted after the blend
!C	is created.
!C
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: double holdline face blend ")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]
DIM Leftgroup$[256]
DIM Rightgroup$[256]
DIM Bodyname1$[256]
DIM Bodyname2$[256]
DIM Edgegroup1$[256]
DIM Edgegroup2$[256]
DIM Name$[256]

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

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

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

Body1= WPKParentBody(E1)
Pkleftgrp= WPKContainingGroup(E1,1,2)
IF NOT WPKIsEntity(Pkleftgrp) THEN Pick_left
Stat= EntityNameCheck(Body1,Bodyname1$)
Stat= EntityNameCheck(Pkleftgrp,Leftgroup$)

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

Body2= WPKParentBody(E1)
Pkrightgrp= WPKContainingGroup(E1,1,2)
IF NOT WPKIsEntity(Pkrightgrp) THEN Pick_right
Stat= EntityNameCheck(Body2,Bodyname2$)
Stat= EntityNameCheck(Pkrightgrp,Rightgroup$)

Pick_holdline1:!
Stat=SetInputFormat("n4")
E2=WPKPickEntity("FIRST HOLDLINE EDGES GROUP",WsPKPickEdge)
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E2) THEN Pick_holdline1
Pktangentgrp= WPKContainingGroup(E2)
IF NOT WPKIsEntity(Pktangentgrp) THEN Pick_holdline1
Stat= EntityNameCheck(Pktangentgrp,Edgegroup1$)

Inverted_holdline1:!
Stat=SetInputFormat("a1=",",N,Y,")
Stat= SetEqualsValue(0,"N")
Stat=GetValue("IS FIRST HOLDLINE INVERTED: Yes or No",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N"
        Invert_holdline1= 0
CASE "Y"
        Invert_holdline1= 1
END SELECT


Pick_holdline2:!
Stat=SetInputFormat("n4")
E3=WPKPickEntity("SECOND HOLDLINE EDGES GROUP",WsPKPickEdge)
IF (ExitScript(Destination$)) THEN Leave

IF NOT WPKIsEntity(E3) THEN Pick_holdline2
Pkconicgrp= WPKContainingGroup(E3)
IF NOT WPKIsEntity(Pkconicgrp) THEN Pick_holdline2
Stat= EntityNameCheck(Pkconicgrp,Edgegroup2$)

Inverted_holdline2:!
Stat=SetInputFormat("a1=",",N,Y,")
Stat= SetEqualsValue(0,"N")
Stat=GetValue("IS SECOND HOLDLINE INVERTED: Yes or No",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N"
        Invert_holdline2= 0
CASE "Y"
        Invert_holdline2= 1
END SELECT

Make_blend:!
WPKClearErrorFlag

Left_sense= WsFalse
Right_sense= WsFalse
Propagate= WsTrue

WPKClearErrorFlag
WPKClearErrorFlag
IF NOT Blend_walls THEN
        Stat= GenerateVarName("Body",Name$)
END IF
RecordFunctionOn
Stat= RecordDescr("BLEND: double holdline blend")
V1= FreeParameter("Propagate on",Propagate)
V2= FreeParameter("Blend trim",Blend_trim)
V4= FreeParameter("Left sense",Left_sense)
V5= FreeParameter("Right sense",Right_sense)

IF Invert_holdline1 AND Invert_holdline2 THEN
Stat= WPKMergeGroups(Edgegroup1$,Edgegroup2$)
G1= WPKBlendFaceGrps(0,Leftgroup$,Rightgroup$,V4,V5,0,V1,V2,Blend_walls,0,0,0,0,Edgegroup1$)
END IF

IF Invert_holdline1 AND NOT Invert_holdline2 THEN
G1= WPKBlendFaceGrps(0,Leftgroup$,Rightgroup$,V4,V5,0,V1,V2,Blend_walls,0,0,Edgegroup2$,0,Edgegroup1$)
END IF

IF NOT Invert_holdline1 AND Invert_holdline2 THEN
G1= WPKBlendFaceGrps(0,Leftgroup$,Rightgroup$,V4,V5,0,V1,V2,Blend_walls,0,0,Edgegroup1$,0,Edgegroup2$)
END IF

IF NOT Invert_holdline1 AND NOT Invert_holdline2 THEN
Stat= WPKMergeGroups(Edgegroup1$,Edgegroup2$)
G1= WPKBlendFaceGrps(0,Leftgroup$,Rightgroup$,V4,V5,0,V1,V2,Blend_walls,0,0,Edgegroup1$)
END IF

IF NOT Blend_walls THEN
        Stat= WPKNameBodyGroup(G1,Name$)
        Stat= WPKSetBodyParent(G1,1)
ELSE
Stat= WPKNameBody(Bodyname1$,Bodyname1$)
Stat= WPKSetBodyParent(Bodyname1$,1)
Stat= WPKRemoveGroup(Pkleftgrp)
Stat= WPKRemoveGroup(Pkrightgrp)
Stat= WPKRemoveGroup(Pktangentgrp)
END IF
Stat= DeleteEntity(G1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= WPKSolidRecordOn(Curr_record)
Stat= AdvanceUndoNumber("double holdline face blend")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck
GOTO Start




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