
! script name: pkpartition.d/readpartition
! solids: read a parasolids partition

!A
!A NAME:
!A
!A 	Read Solid Partition
!A
!A DESCRIPTION:
!A		
!A	This script will read a previously stored parasolid partition file.
!A	Partition files have the suffix .P_T or .P_B. Along with the
!A	partition file should be a file containing the partition
!A	changes, this file is called a deltas file and has the suffix
!A	.D_T or .D_B. If the deltas file is not present a partition
!A	may not be rolled back.
!A
!B NOTES:
!B
!B	Partition files which are read may be rolled back to earlier
!B	states. The degree to which a partition may be rolled back
!B	depends on the state in which it was stored.
!B
!B	Standard parasolid files have the suffix .X_T ot .X_B. In these
!B	files all bodies are in a single partition and rollback
!B	is not permitted.
!B
!# see also - htdocs/help.d/partitions.htm
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function: read solid partition ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[512]
DIM Dir$[512]
DIM Dir1$[512]
DIM Default$[512]


DeActivateUndo

Default$= "C:/usr/weber/ST/solids/"
Stat= NamedVarStr("solid file dir",WsSystemVars,Default$,Dir$)

	D_label$="DIRECTORY"
	Sub_label$="SUB DIRECTORIES"
	F_label$="FILES"
	Choice$="FILE TO OPEN"
	Mask$="[A-Za-z0-9]*"

	Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$,"Synergy")
	Stat=SetInputFormat("a99","")
	Stat=GetValue("SELECT EXISTING JOB FILE",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
	IF Answer$= "CANCEL" THEN Leave
	LowerFileBox
	IF NamedVarVal("save dirs",WsSystemVars,0) THEN V1=CreateVariable("solid file dir",WsSystemVars,PathNameDirectory(Answer$))
Name$= Answer$


Group= WPKReadPartition(Name$,WsFalse,WsTrue)
Stat= DeleteEntity(Group)

ActivateUndo
Stat= AdvanceUndoNumber("read solid partition")
Stat= AddItemToUndo(WsUBPKSessionMark)
ResizeAll
WPKSetRotateCenter


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