
! script name: project.d/projectcont
! topic: project contour

!A
!A NAME:
!A
!A 	Project Contour
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be projected.  The data selected
!A 	will project the data into the current workplane and then position
!A 	it into the xy plane.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE PROJECTED: Pick an element on the group to be
!B 		projected.  This question is for a PICK A GROUP mode only.
!B
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: project contour ")

DIM Answer$[256]
DIM Destination$[256]
DEG

stat= SetInputFormat("n4","")


Start: !
ActivateUndo


Group=PickGroupEnt("PICK CONTOUR TO BE PROJECTED")
IF (ExitScript(Destination$)) THEN Leave
IF (NOT ValidGeometry(Group)) THEN Start


stat= SetInputFormat("n4=","")
stat= SetEqualsValue(0)
Zconst=GetValue("Z CONSTANT",Answer$)
IF (ExitScript(Destination$)) THEN Leave


stat= SetInputFormat("n4=","")
stat= SetEqualsValue(1.0)
Scale_factor= GetValue("SCALE FACTOR",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Pz= PointXYZ(0,0,0)

Work=CurrentWorkplane
IF (ValidGeometry(Work)) THEN Active_workplane= 1

Delete_scaled=0
IF Scale_factor <> 1 THEN
	G1=ScaleGroup(Group,Pz,Scale_factor)
	Delete_scaled=1
	Group= G1
END IF
Stat= DeleteEntity(Pz)


IF Active_workplane THEN
	Contour2= ProjectEntity(Group,Zconst,Work)
ELSE
	Contour2= ProjectEntity(Group,Zconst)
END IF
IF (ValidGeometry(Contour2)) THEN
	stat= DelMatchingEnts(Contour2)

	IF Delete_scaled THEN
		Stat= DeleteGroup(Group,1)
	END IF


	N1=GroupCount(Contour2)
	IF (N1=0) THEN
       		Stat=DeleteEntity(Contour2)
	ELSE
		Stat= ChangeGroupType(Contour2,WsContourGroup)
       		Stat=AutoNumber(Contour2)
	END IF

	ActivateUndo
	Stat= AdvanceUndoNumber("project")
	Stat= AddGroupToUndo(WsUBCreateMode,Contour2,1,WsTrue)

END IF

Leave:!
IF Active_workplane THEN
        Stat=SetWorkplane(Work)
ELSE
        StdWorkplane
END IF

stat= SetInputFormat("n4","")
Stat=DeleteEntity(Pc)
Stat=DeleteEntity(Pz)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END


