
! script name: move.d/worktoorigin
! topic: move from a workplane to the origin

!A
!A NAME:
!A
!A 	Move From a workplane to the origin
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of entities to have their data transformed
!A 	from a  workplane to the origin.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTITY FOR WORKPLANE: Pick an entity on the original
!B 		workplane.
!B
!B 	SELECT VIEW FOR SELECTION BOX: Select the view containing the entities.
!B
!B 	PICK FIRST CORNER OF PICK ZONE: Pick a corner of the box.
!B
!B 	PICK SECOND CORNER OF PICK ZONE: Pick the other corner of the view box.
!B
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: workplane to origin move ")

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

ActivateUndo
stat= SetInputFormat("n4","")
Active_workplane=0
Current_work=CurrentWorkplane
IF ValidGeometry(Current_work) THEN Active_workplane=1


Pick_workplane:StdWorkplane
Origin_ent=PickEntity("PICK ENTITY FOR WORKPLANE")
IF (ExitScript(Destination$)) THEN Leave

Origin_plane=GetTransform(Origin_ent)
IF NOT ValidGeometry(Origin_plane) THEN Pick_workplane

StdWorkplane
Group=CreateGroup("TEMP")

Vnum=PickView("SELECT VIEW FOR SELECTION BOX")
IF (ExitScript(Destination$)) THEN Leave

Stat=PickBox(Group,Vnum,WsPickPen)
IF (ExitScript(Destination$)) THEN Leave

StdWorkplane
Inv_work=InverseTrans(Origin_plane)
Stat= EraseEntity(Group)

ActivateUndo
Stat= AdvanceUndoNumber("move")
Stat= AddGroupToUndo(WsUBModifyMode,Group,2,WsTrue)

Stat= TransGroupTrans(Group,Inv_work,1)
Stat= PlotEntity(Group)

PlotAll

Leave:!
IF Active_workplane THEN
	Stat=SetWorkplane(Current_work)
ELSE
	StdWorkplane
END IF
stat= SetInputFormat("n4","")
Stat=DeleteEntity(Group)
Stat=DeleteEntity(G1)
Stat=DeleteEntity(Pr)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END




