
! script name: vpksoliddraft.d/vpkexplodeview
! var_solids: explode a view of a solid model

!A
!A NAME:
!A
!A 	Explode View  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A	This script explodes the geometry of a view of a parasolids
!A	model. The Orthographic views will make hidden lines dashed.
!A	The Isometric views will remove hidden lines.
!A
!A~ image location - images/pkexplodeview.gif
!A
!B INSTRUCTIONS:
!B
!B	VIEW  Top Front Right Left Iso Back Underside
!B
!B	POSITION: Input the position where the view will be placed.
!B
!C NOTE:
!C
!C	This function has been modified 8/15/01
!C
!C	Previously all of the solid model was exploded in the view.
!C
!C	Now only bodies which satisfy the visible layers, and colors
!C	will be exploded. In addition hidden bodies will not be
!C	exploded unless hidden ents are to be visible.
!C
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: explode view ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Center$[256]

ActivateUndo
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave


Start:!
Hidden_mode= 2
Smooth_edges=WsFalse
Stat=SetEqualsValue(0,"T")
Stat=SetInputFormat("a2=",",T,TS,F,FS,L,LS,R,RS,B,BS,U,US,I,IS,I2,I3,I4,")
Stat=GetValue("VIEW  Top Front Right Left Iso Back Underside  ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "T"
	Descr$= "explode top view"
	Xangle=0
	Yangle=0
	Zangle=0
	Orient_angle= 0
CASE "TS"
        Descr$= "explode top view"
	Xangle=0
        Yangle=0
        Zangle=0
        Orient_angle= 0
        Smooth_edges=WsTrue
CASE "U"
	Descr$= "explode underside view"
	Xangle=180
        Yangle=0
        Zangle=0
        Orient_angle= 180
CASE "US"
        Descr$= "explode underside view"
	Xangle=180
        Yangle=0
        Zangle=0
        Orient_angle= 180
        Smooth_edges=WsTrue
CASE "F"
	Descr$= "explode front view"
	Xangle=90
        Yangle=0
        Zangle=0
        Orient_angle= 0
CASE "FS"
        Descr$= "explode front view"
	Xangle=90
        Yangle=0
        Zangle=0
        Orient_angle= 0
        Smooth_edges=WsTrue
CASE "B"
	Descr$= "explode back view"
	Xangle=-90
        Yangle=0
        Zangle=0
        Orient_angle= 0
CASE "BS"
        Descr$= "explode back view"
	Xangle=-90
        Yangle=0
        Zangle=0
        Orient_angle= 0
        Smooth_edges=WsTrue
CASE "R"
	Descr$= "explode right view"
	Xangle=-90
        Yangle=-90
        Zangle=0
        Orient_angle= 90
CASE "RS"
        Descr$= "explode right view"
	Xangle=-90
        Yangle=-90
        Zangle=0
        Orient_angle= 90
        Smooth_edges=WsTrue
CASE "L"
	Descr$= "explode left view"
	Xangle=90
        Yangle=90
        Zangle=0
        Orient_angle= -90
CASE "LS"
        Descr$= "explode left view"
	Xangle=90
        Yangle=90
        Zangle=0
        Orient_angle= -90
        Smooth_edges=WsTrue
CASE "I"
	Descr$= "explode iso view"
	Xangle=60
        Yangle=0
        Zangle=30
        Orient_angle= 0
	Hidden_mode= 1
CASE "IS"
	Descr$= "explode iso view"
	Xangle=60
        Yangle=0
        Zangle=30
        Orient_angle= 0
        Smooth_edges=WsTrue
	Hidden_mode= 1
CASE "I2"
	Descr$= "explode iso view"
        Xangle=60
        Yangle=0
        Zangle=-30
        Orient_angle= 0
        Hidden_mode= 1
CASE "I3"
	Descr$= "explode iso view"
        Xangle=60
        Yangle=0
        Zangle=-150
        Orient_angle= 0
        Hidden_mode= 1
	
CASE "I4"
	Descr$= "explode iso view"
        Xangle=60
        Yangle=0
        Zangle=150
        Orient_angle= 0
        Hidden_mode= 1
END SELECT


Pick_point:Stat=SetInputFormat("n4=","")
Pc=XyzInput("LOCATION POINT",WsXyzInput)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pc) THEN Pick_point
E1= LastPickEnt
Pick_para= LastPickPara
Pick_return= CurrPickReturn
IF NOT ValidDependency(E1) THEN
        E1= CopyEntity(Pc)
        Stat= EntityNameCheck(E1,Center$)
        Pc_created= WsTrue
ELSE
        Stat= EntityNameCheck(E1,Center$)
        Pc_created= WsFalse
END IF
Stat=SetLastPoint(Pc)
Stat= DeleteEntity(Pc)



WPKClearErrorFlag
Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("VIEW:"&Descr$)
SELECT Pick_return
CASE WsGeometryEnd
        Pc= ParameterReturnPt(Center$,Pick_para,WsGeometryEnd)
CASE WsGeometryMid
        Pc= ParameterReturnPt(Center$,Pick_para,WsGeometryMid)
CASE WsGeomCenter
        Pc= ParameterReturnPt(Center$,Pick_para,WsGeomCenter)
END SELECT
V1= FreeParameter("X Angle",Xangle)
V2= FreeParameter("Y Angle",Yangle)
V3= FreeParameter("Z Angle",Zangle)
V4= FreeParameter("Orient Angle",Orient_angle)
Pt= PointXYZ(0,0,0)
Trans1=AngleTransform(Pt,V1,V2,V3)
V5= FreeParameter("Hidden mode",Hidden_mode)
V6= FreeParameter("Smooth edges",Smooth_edges)
Group= WPKExplodeView(Trans1,V5,V6,Pc,0.0,0.0,V4)
Stat= DeleteEntityList(Pt,Pc)
Stat= AutoNameGroup(Group,Name$)
RecordFunctionOff
IF ValidGeometry(Group) THEN
        Stat= PlotEntity(Group)
        ActivateUndo
        Stat= AdvanceUndoNumber(Descr$)
	IF Pc_created THEN Stat= AddItemToUndo(WsUBCreateMode,Center$)
        Stat= AddGroupToUndo(WsUBCreateMode,Group,0,WsTrue)
        Keep_record= WsTrue
ELSE
	IF Pc_created THEN Stat= DeleteEntity(Center$)
        Keep_record= WsFalse
END IF
RecordFunctionOn
Stat= DeleteEntity(Group)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

IF Keep_record= WsFalse THEN
        DelLastVarRecord
ELSE
        Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Start



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