
! script name: pkpartition.d/savepartition
! solids: save a partition from a parasolids session

!A
!A NAME:
!A
!A 	Save Partition
!A
!A DESCRIPTION:
!A
!A	This function will save a single partition from the parasolids model
!A	contained in the current synergy session into a file with the
!A	suffix .P_T. Along with the partition file is a file containing
!A	the partition changes this file is called a deltas file and
!A	has the suffix .D_T.
!A
!B NOTES:
!B
!B	A partition file when read back allows the partition to
!B	be rolled backward to a previous state.
!B
!B	Partition files have the suffix .P_T or .P_B
!B	Partition delta files have the suffix .D_T or .D_B.
!B
!B	Standard Parasolid files have the suffix .X_T or .X_B
!B
!# see also - htdocs/help.d/partitions.htm
!# see also - htdocs/help.d/parasolids.htm

stat=ChangeLabelStr("ScriptNameStatus","Function:  save parasolids partition ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[512]
DIM Dir$[512]
DIM Dir1$[512]
DIM Default$[512]
DIM D_label$[256],Sub_label$[256],F_label$[256],Choice$[256]
DIM Mask$[256],Space$[256],Jobname$[256]



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


Pick_body:!
Pkent=WPKPickEntity("PICK ENTITY IN PARTITION")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(Pkent) THEN Pick_body

Question:!
D_label$="DIRECTORY"
Sub_label$="SUB DIRECTORIES"
F_label$="FILES"
Choice$="FILE TO SAVE"
Mask$="[A-Za-z0-9]*"
Stat=UserFileBox(Dir$,Mask$,D_label$,Sub_label$,F_label$,Choice$,"Synergy")
Ques2:!
Stat=SetInputFormat("a99","")
Stat=GetValue("SAVE JOB AS: "&Space$,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NamedVarVal("save dirs",WsSystemVars,0) THEN V1=CreateVariable("solid file dir",WsSystemVars,PathNameDirectory(Answer$))

!  IF POS(Answer$," ") THEN
!           Space$= " (NO SPACES) "
!           GOTO Ques2
!  ELSE
!          Space$= " "
!  END IF
IF NOT POS(Answer$,"/") THEN
        Jobname$= FileNameString(Dir$,Answer$)
ELSE
        Testposr=1
        REPEAT
            Testpos=POS(Answer$[Testposr],"/")
            Testposr=Testposr+Testpos
        UNTIL (NOT Testpos)
        Namelen=LEN(Answer$)-Testposr+1

        IF NOT Namelen THEN Ques2
        Jobname$= Answer$
END IF
LowerFileBox


Name$= Jobname$
n1= POS(Name$,".x_t")
IF N1 THEN Name$= Name$[1,n1-1]
n1= POS(Name$,".X_T")
IF N1 THEN Name$= Name$[1,n1-1]


Stat= WPKSavePartition(Pkent,Name$)


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