public static void WriteCircles(string pmlpath , string objname , IList <Circle> lst_circle //, int numLinesInCircle = 50 //, double? linewidth = null //, double alpha=1.0, double red=1.0, double green=1.0, double blue=1.0 , bool append = false ) { StreamWriter file; if (append) { file = HFile.AppendText(pmlpath); } else { file = HFile.CreateText(pmlpath); } { //StreamWriter file = File.AppendText(pypath); file.WriteLine("from pymol.cgo import *"); file.WriteLine("from pymol import cmd"); file.WriteLine("obj = ["); foreach (var circle in lst_circle) { //Vector center = center_normal_radii_numseg_color_width.Item1; //Vector normal = center_normal_radii_numseg_color_width.Item2; //double radii = center_normal_radii_numseg_color_width.Item3; //int numLinesInCircle = center_normal_radii_numseg_color_width.Item4; //double? alpha = center_normal_radii_numseg_color_width.Item5.Item1; //double? red = center_normal_radii_numseg_color_width.Item5.Item2; //double? green = center_normal_radii_numseg_color_width.Item5.Item3; //double? blue = center_normal_radii_numseg_color_width.Item5.Item4; //double? linewidth = center_normal_radii_numseg_color_width.Item6; Trans3 trans = Trans3.GetTransformNoScale(new double[3] { 0, 0, 0 } , new double[3] { 0, 0, 1 } , circle.center , circle.center + circle.normal.UnitVector() ); Vector[] pts = new Vector[circle.numLinesInCircle + 1]; double di = (2 * Math.PI) / circle.numLinesInCircle; for (int i = 0; i < circle.numLinesInCircle; i++) { Vector lpt = new double[3] { circle.radii *Math.Cos(di * i), circle.radii *Math.Sin(di * i), 0 }; pts[i] = trans.DoTransform(lpt); } pts[circle.numLinesInCircle] = pts[0]; file.Write("BEGIN, LINE_STRIP, "); if (circle.linewidth != null) { file.Write("LINEWIDTH, {0:0.000}, ", circle.linewidth); } if (circle.alpha != null) { file.Write("ALPHA, {0:0.000},", circle.alpha); } if (circle.color != null) { file.Write("COLOR, {0:0.000}, {1:0.000}, {2:0.000}, ", circle.color.Item1, circle.color.Item2, circle.color.Item3); } for (int i = 0; i < pts.Length; i++) { if (i % 10 == 0) { file.WriteLine(); file.Write(" "); } file.Write("VERTEX, {0:0.000}, {1:0.000}, {2:0.000}, ", pts[i][0] + 0.000001, pts[i][1] + 0.000001, pts[i][2] + 0.000001); } file.WriteLine(); file.WriteLine(" END, "); } file.WriteLine("]"); // file.WriteLine("cmd.load_cgo(obj,\"channel_path\")"); file.WriteLine("cmd.load_cgo(obj,\"" + objname + "\")"); file.WriteLine(); } file.Close(); }