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

!A
!A NAME:
!A
!A 	Move From origin to a workplane.
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of entities to have their data transformed
!A 	from the origin to a workplane.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTITY FOR WORKPLANE: Pick an entity on the original 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: origin to workplane 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
Dest_ent=PickEntity("PICK ENTITY FOR WORKPLANE")
IF (ExitScript(Destination$)) THEN Leave

Dest_plane=GetTransform(Dest_ent)
IF NOT ValidGeometry(Dest_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
Stat= EraseEntity(Group)
ActivateUndo
Stat= AdvanceUndoNumber("move")
Stat= AddGroupToUndo(WsUBModifyMode,Group,2,WsTrue)

Stat= TransGroupTrans(Group,Dest_plane,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




