//**************************************************
//	Digit Widgets Utility Module
// 	Just some useful Utilities, add your own! 
//	Made to be called from Hyperlinked Digit_Widgets Script
//
// Version 3.0 - 09/12/01 - Added Animation Script to Widgets
//	Version 3.1 - 09/15/01 - Updated with Advanced and Standard Animation Scripts
//**************************************************
<zscriptinsert,"Digit_Widgets_Common.txt">

[PD]
[FontSetColor,255,200,0]3D Plane Angle Utility[FontSetColor,160,160,160]
[PD]
//*****************Plane Angle*******************************
[iSlider,"Rotate1                  ",0,5,-90,90,"Plane Angle",,0,[TextCalcWidth,SizeIncr4123]]
[IButton,"Make Plane","Create and Rotate a Ground Plane",
	[iPress,tool:plane3D]
	[VarSet,rot1,zscript:Rotate1]
	[canvasclick,docMidX,docMidY,docWidth,docHeight]
	[transformSet,,,,docMidX,docMidy,,rot1,0,0]
]
[PD]
[FontSetColor,255,200,0]3D Prep a 3D Cylinder Utility[FontSetColor,160,160,160]
[PD]
//****************Prep Cylinder*****************************
[VarDef,CenterZ,0]
[iSlider,"ScalX  ",0,.1,-1000,DocWidth,"Manipulate  X ", [varSet,TransXS,zscript:ScalX],0,[TextCalcWidth,SizeIncr4123]]
[iSlider,"ScalY  ",0,.1,-1000,DocHeight,"Manipulate Y",[varSet,TransYS,zscript:ScalY],0,[TextCalcWidth,SizeIncr4123]]
[iSlider,"ScalZ  ",0,.1,-2000,2000,"Manipulate  Z",[varSet,TransZS,zscript:ScalZ],0,[TextCalcWidth,SizeIncr4123]]
[iSlider,"Center  ",0,.1,-100,100,"Center Point",[varSet,CenterZ,zscript:Center],0,[TextCalcWidth,SizeIncr4123]]
[IButton,Prep Cylinder,"Set XY to  and lengthen X and adjust imbed.",
	[IPress,TOOL:Cylinder3D]
	[ISet,TOOL:MODIFIERS:INITIALIZE:X Size,100]
	[ISet,TOOL:MODIFIERS:INITIALIZE:X Size,25]
	[ISet,TOOL:MODIFIERS:INITIALIZE:Y Size,100]
	[ISet,TOOL:MODIFIERS:INITIALIZE:Y Size,25]
	[IModSet,TOOL:MODIFIERS:DEFORMATION:Offset,0]
	[IModSet,TOOL:MODIFIERS:DEFORMATION:Offset,4]
	[ISet,TOOL:MODIFIERS:DEFORMATION:Offset,0]
	[ISet,TOOL:MODIFIERS:DEFORMATION:Offset,CenterZ]
	[CanvasStroke,(ZObjStrokeV01n53x2=H253V263H253V263H253V264H253V265H253V266H254V267H254V268H254V269H254V270H255V271H255V272H255V273H256V273H256V274H256V277H257V278H257V279H257V282H257V283H257V284H257V285H257V286H257V287H257V288H257V289H257V290H257V291H257V292H257V295H257V296H258V297H258V298H258V301H258V302H258V305H258V306H258V309H258V310H258V313H258V314H258V315H258V318H258V319H259V319H259V320H259V321H259V322H259V323H260V324H260V325H261V325H262V326H262V326)]
	[IPress,TRANSFORM:MOVE]
	[transformSet,,,,TransXS,TransYS,TransZS]
]
[PD]
[FontSetColor,255,200,0]3D Remove Visible Edge Utility[FontSetColor,160,160,160]
[PD]
[IButton,"Remove Edge","This function removes the visible edge from an imported 3D object",
	[IPress,TOOL:PolyMesh3D]
	[ISet,TOOL:INVENTORY:WELD,0.001]
	[IPress,TOOL:INVENTORY:IMPORT]
	[IPress,TOOL:INVENTORY:EXPORT]
]

[PD]
[FontSetColor,255,200,0]Make a Rope [FontSetColor,160,160,160]
[PD]
[IButton,"Rope","Prepare a Cube3D Rope",
	[IPress,TOOL:Cube3D]
	[ISet,TOOL:Modifiers:Initialize:XSize,6]
	[ISet,TOOL:Modifiers:Initialize:YSize,6]
	[ISet,TOOL:Modifiers:Initialize:SidesCount,6]
	[ISet,TOOL:Modifiers:Initialize:HDivide,30]
	[ISet,TOOL:Modifiers:Initialize:VDivide,45]
	[ISet,TOOL:Modifiers:Initialize:Twist,100]
	[ISet,TOOL:Modifiers:Initialize:Twist,100]
	[ISet,TOOL:Modifiers:Initialize:Twist,100]
	[ISet,TOOL:Modifiers:Initialize:Twist,100]
	[ISet,TOOL:Modifiers:Initialize:Twist,100]
	[ISet,TOOL:Modifiers:Initialize:Twist,100]
	[MessageOK,"Done apply to canvas and continue to edit"]
]
[PD]
[FontSetColor,255,200,0]Center and Size a 3D Line between Marks [FontSetColor,160,160,160]
[PD]
[iSlider,"StartMark  ",1,1,1,10,"Starting Mark",[varSet,sel1,zscript:StartMark],0,[TextCalcWidth,XYAngle12345]]
[iSlider,"EndMark    ",2,1,1,10,"Ending Mark",[varSet,sel2,zscript:EndMark],0,[TextCalcWidth,XYAngle12345]]
[iSlider,"Distance   ",2,.1,0,4000,"3D Distance between Marks",,0,[TextCalcWidth,XYAngle12345]]
[IButton,"3D Line","Make a 3D Line using the current object",
	//find center
	[VarSet,sel1,[Iget,zscript:StartMark]]
	[VarSet,sel2,[Iget,zscript:EndMark]]
	//Do the line
	[RoutineCall,MakeLine,MarkX(sel1),MarkX(sel2),MarkY(sel1),MarkY(sel2),MarkZ(sel1),MarkZ(sel2),MarkZR(sel2)]
	//make scaling right
	[TransformSet,,,,MarkXS(sel2),MarkYS(sel2)]
	//distance is returned with DDistToMark
	[ISet,zscript:Distance,DDistToMark*.5]
]
[PD]
[FontSetColor,255,200,0]Press Grabline and Click and Drag to make a 3D Line between two points [FontSetColor,160,160,160]
[PD]
[iSlider,"LineDiameter  ",10,1,1,500,"Line Diameter",[varSet,Ldiam,zscript:LineDiameter],0,[TextCalcWidth,XYAngle12345]]

[iButton," MakeALine ","Press to Start then use Mouse and drag from start to end",
	[RoutineCall,Mouselook,Hval1,Vval1,Hval2,Vval2,Clicked]
	//we know we always want to look at first position
	[if,Clicked = 1,
		[RoutineCall,PixolLook,Hval1,Vval1,1,Zval1,tmp,tmp,tmp]
		[RoutineCall,PixolLook,Hval2,Vval2,1,Zval2,tmp,tmp,tmp]
		//figure out the line here now that we have the Z values and positions	
		//place current selection on canvas and go to edit
		[canvasClick,320,258,320,264]
		[iPress,transform:Move]

		//Do the line
		[RoutineCall,MakeLine,Hval1,Hval2,Vval1,Vval2,Zval1,Zval2,0]
		//make scaling right
		[TransformSet,,,,Ldiam,Ldiam]
	]
] // end iButton
[PD]
[VarDef,Point1x,0]
[VarDef,Point1y,0]
[IButton,"RandomGear","Make a Random Gear",
	// Set the color to slightly varying shades of gold
	[IColorSet,225+rand(30),170+rand(30),64]

	// Set the gear to maximum resolution
	[ISet,TOOL:MODIFIERS:INITIALIZE:SDivide,128]
	[ISet,TOOL:MODIFIERS:INITIALIZE:LDivide,512]


	// Set the gear in the center and 1000 units back
	[transformSet,DocMidX,DocMidY,1000,100,100,100,0,0,0]

	// Set some random points in the cross-section
	[loop,5,
		[VarSet,point1x,rand(117)]
		[VarSet,point1y,rand(117)]
		[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Section,point1x,point1y,-200,-200,point1x,point1y]
	]

	// Move the point at the right all the way to the bottom of the ZGraph
	// For some reason, this was the only point I could change via the ZScript
	[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,117,61,117,117]

	// Set some random points in the Outer Profile	
	[loop,7,
		[VarSet,point1x,rand(117)]
		[VarSet,point1y,rand(117)]
		[IClick,TOOL:MODIFIERS:INITIALIZE:Outer Profile,point1x,point1y,-200,-200,point1x,point1y]
	]

	// Set some random points in the Inner Section
	[IClick,TOOL:MODIFIERS:INITIALIZE:Inner Section,23,10,-100,-100,rand(29),rand(115)]
	[IClick,TOOL:MODIFIERS:INITIALIZE:Inner Section,46,10,-100,-100,23+rand(29),rand(115)]
	[IClick,TOOL:MODIFIERS:INITIALIZE:Inner Section,69,10,-100,-100,46+rand(29),rand(115)]
	[IClick,TOOL:MODIFIERS:INITIALIZE:Inner Section,92,10,-100,-100,69+rand(29),rand(115)]
	[IClick,TOOL:MODIFIERS:INITIALIZE:Inner Section,115.10,-100,-100,92+rand(29),rand(115)]

	// Set Width, Skew, Outer Radial Count, Inner Radial Count, Outer Size, Inner Radius and Tilt to Random Values
	[ISet,TOOL:MODIFIERS:INITIALIZE:Width,5+rand(70)]
	[ISet,TOOL:MODIFIERS:INITIALIZE:Skew,-100+rand(200)]
	[ISet,TOOL:MODIFIERS:INITIALIZE:OuterRC,6+rand(10)]
	[ISet,TOOL:MODIFIERS:INITIALIZE:InnerRC,3+rand(7)]
	[ISet,TOOL:MODIFIERS:INITIALIZE:OuterS,20+rand(80)]
	[ISet,TOOL:MODIFIERS:INITIALIZE:IRadius,10+rand(90)]
	[ISet,TOOL:MODIFIERS:INITIALIZE:Tilt,340+rand(20)]

	// This is so the gear can be scaled uniformly in all directions
	[varSet,Scale,50+rand(140)]
]
[PD]
[IButton,"RandomHelix","Make a Random Gear",
	// Set the color to slightly varying shades of gold
	[IColorSet,225+rand(30),170+rand(30),64]

	// Set the gear to maximum resolution
	[ISet,TOOL:MODIFIERS:INITIALIZE:SDivide,128]
	[ISet,TOOL:MODIFIERS:INITIALIZE:LDivide,512]


	// Set the gear in the center and 1000 units back
	[transformSet,DocMidX,DocMidY,1000,100,100,100,0,0,0]

	// Set Width, Skew, Outer Radial Count, Inner Radial Count, Outer Size, Inner Radius and Tilt to Random Values
	[ISet,TOOL:MODIFIERS:INITIALIZE:Coverage,1+rand(359)]

	// Move the point at the right all the way to the bottom of the ZGraph
	// For some reason, this was the only point I could change via the ZScript
	[IClick,TOOL:MODIFIERS:INITIALIZE:Profile,117,61,117,117]

	// Set some random points in the cross-section
	[loop,7,
		[VarSet,point1x,rand(117)]
		[VarSet,point1y,rand(117)]
		[IClick,TOOL:MODIFIERS:INITIALIZE:Profile,point1x,point1y,-200,-200,point1x,point1y]
	]

	// Set some random points in the Outer Profile
	[loop,3,
		[VarSet,point1x,rand(117)]
		[VarSet,point1y,rand(117)]
		[IClick,TOOL:MODIFIERS:INITIALIZE:Thickness,point1x,point1y,-200,-200,point1x,point1y]
	]

	// Set some random points in the Outer Profile graph
	[loop,4,
		[VarSet,point1x,rand(117)]
		[VarSet,point1y,rand(117)]
		[IClick,TOOL:MODIFIERS:INITIALIZE:Radius,point1x,point1y,-200,-200,point1x,point1y]
	]
	// Set some random points in the Inner Section
	[IClick,TOOL:MODIFIERS:INITIALIZE:ZOffset,23,10,-100,-100,rand(29),rand(115)]
	[IClick,TOOL:MODIFIERS:INITIALIZE:ZOffset,46,10,-100,-100,23+rand(29),rand(115)]
	[IClick,TOOL:MODIFIERS:INITIALIZE:ZOffset,69,10,-100,-100,46+rand(29),rand(115)]
	[IClick,TOOL:MODIFIERS:INITIALIZE:ZOffset,92,10,-100,-100,69+rand(29),rand(115)]
	[IClick,TOOL:MODIFIERS:INITIALIZE:ZOffset,115.10,-100,-100,92+rand(29),rand(115)]

	[IClick,TOOL:MODIFIERS:INITIALIZE:Twist,115.10,-100,-100,92+rand(29),rand(115)]

	// This is so the gear can be scaled uniformly in all directions
	[varSet,Scale,50+rand(140)]
]
[PD]
[PD]
<zscriptinsert,"Widgets_Index_Include.txt">
[PD]
[PD]
[fontSetSizeSmall]\C00e0e0Digit Widget Utility Revision 3.3, created by Digits\Cc0c0c0
