Problems creating a package file
- To: mathgroup at smc.vnet.net
- Subject: [mg77056] Problems creating a package file
- From: chuck009 <dmilioto at comcast.com>
- Date: Sat, 2 Jun 2007 04:14:45 -0400 (EDT)
Hello everyone.
I'd like to create my own package of some plotting routines but I'm having problems getting routines to work within the package. I suspect my context is not right. I created PlotRoutines.m via File/SaveAsSpecial/PackageFormat and placed it in a PlotUtilities directory within the ExtraPackages directory:
(*
PlotRoutines.m
Package for plot routines *)
BeginPackage["PlotUtilities`PlotRoutines`"];
TagPoints::usage = "Tag Polygons with '1' which satisfy passed inequality"
Begin["`Private`"];
TagPoints[inequality_][p_] :=
Block[{x, y, z}, {x, y, z} = p; If[inequality, {p, 1}],{p, 2}]];
End[];
EndPackage[];
It takes a Graphics3D object and tests each coordinate of each Polygon matching the search criteria specified in the inequality and is suppose to append either a 1 or a 2 to each coordinate. I'd call it as:
<< PlotUtilities`PlotRoutines`
p1=Graphics3D[Plot3D[some plot here]]
p1 /. Polygon[pts_] :> Polygon[TagPoints[z â?¥ 2] /@ pts];
However it doesn't update the polygons and I know it works when I create the TagPoints function within the notebook. Also, I noticed when I first create the *.m file, Mathematica adds (* *) to the file which I remove. Not sure what to do. Can someone help me?