Skip to content

Commit 0aebba4

Browse files
Add files via upload
1 parent 6c80e80 commit 0aebba4

27 files changed

+473
-83
lines changed

GH_CPython/GH_CPython.v12.suo

-7 KB
Binary file not shown.

GH_CPython/GH_CPython/DataManagement.Designer.cs

Lines changed: 186 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GH_CPython/GH_CPython/DataManagement.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ public DataManagement()
1818
}
1919

2020

21+
2122
}
2223
}

GH_CPython/GH_CPython/GH_CPython.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@
198198
<ItemGroup>
199199
<Content Include="draft.txt" />
200200
<Content Include="draft2.txt" />
201+
<None Include="Resources\pip-icon.png" />
202+
<None Include="Resources\reset24.png" />
203+
<None Include="Resources\save_as_24.png" />
204+
<None Include="Resources\saveIcon24.png" />
201205
<None Include="Resources\tree12.png" />
202206
<None Include="Resources\list12.png" />
203207
<None Include="Resources\item12.png" />

GH_CPython/GH_CPython/Gh_CPythonComponent.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public Gh_CPythonComponent()
9494
path = initfunc.isPythonFloderExists(@"C:\GH_CPython\");
9595

9696
//2- Look for and set Python.exe interpreter if not set
97-
initfunc.getPythonInterpretere(@"C:\GH_CPython\interpreter.dat", defaultFileName, StartFileName);
97+
StartFileName = initfunc.getPythonInterpretere(@"C:\GH_CPython\interpreter.dat");
9898

9999
//3- Add latest version of required python modules if not existed
100100
initfunc.addGrasshopperPyModule(@"C:\GH_CPython\Grasshopper.py", pythonVersion);
@@ -207,9 +207,17 @@ void manageDataItem_Click(object sender, EventArgs e)
207207

208208
DM = new DataManagement();
209209

210+
PythonIDE.TopMost = false;
211+
212+
DM.TopMost = true;
213+
210214
DM.Show();
211215

212-
DM.cancelButton.Click += (s, ev) => { DM.Close(); };
216+
DM.cancelButton.Click += (s, ev) => {
217+
218+
DM.Close();
219+
220+
};
213221

214222
DM.applyButton.Click += (se, ev) =>
215223
{
@@ -222,13 +230,15 @@ void manageDataItem_Click(object sender, EventArgs e)
222230
List<string> inputStrings = new List<string>();
223231
Dictionary<string, int> dAccess = new Dictionary<string, int>();
224232
Dictionary<string, int> dINdex = new Dictionary<string, int>();
233+
Dictionary<string, string> dDesc = new Dictionary<string, string>();
225234

226235
for (int i = 0; i < Params.Input.Count; i++)
227236
{
228237
int access = Params.Input[i].Access == GH_ParamAccess.item ? 0 : Params.Input[i].Access == GH_ParamAccess.list ? 1 : 2;
229238
inputStrings.Add(Params.Input[i].NickName);
230239
dAccess.Add(Params.Input[i].NickName, access);
231240
dINdex.Add(Params.Input[i].NickName, i);
241+
dDesc.Add(Params.Input[i].NickName, Params.Input[i].Description);
232242
}
233243
DM.inputList.DataSource = inputStrings;
234244

@@ -240,6 +250,7 @@ void manageDataItem_Click(object sender, EventArgs e)
240250
{
241251
string selItem = DM.inputList.SelectedValue.ToString();
242252
DM.dAccesslist.SetSelected(dAccess[selItem],true);
253+
DM.description.Text = dDesc[selItem];
243254
}
244255
catch (Exception err)
245256
{
@@ -252,13 +263,16 @@ void manageDataItem_Click(object sender, EventArgs e)
252263
string selItem = DM.inputList.SelectedValue.ToString();
253264
int selectedindex = DM.dAccesslist.SelectedIndex;
254265
Params.Input[dINdex[selItem]].Access = selectedindex == 0 ? GH_ParamAccess.item : selectedindex == 1 ? GH_ParamAccess.list : GH_ParamAccess.tree;
255-
//MessageBox.Show(dINdex[selItem].ToString() + " -> " + selectedindex.ToString());
266+
dAccess[selItem] = selectedindex;
267+
256268
};
257269

258270
}
259271

260272
void DM_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
261273
{
274+
PythonIDE.TopMost = true;
275+
262276
ExpireSolution(true);
263277
}
264278

@@ -295,6 +309,7 @@ void Gh_CPythonComponent_PreviewExpired(IGH_DocumentObject sender, GH_PreviewExp
295309
MessageBox.Show(exc.ToString());
296310
}
297311
AddNamesAndDescriptions();
312+
StartFileName = initfunc.getPythonInterpretere(@"C:\GH_CPython\interpreter.dat");
298313
Grasshopper.Instances.RedrawCanvas();
299314
}
300315

@@ -544,6 +559,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
544559
path);
545560

546561
RunningPythonProcess.StartInfo.FileName = @StartFileName;
562+
//MessageBox.Show(@StartFileName);
547563
RunningPythonProcess.StartInfo.Arguments = path + name + ".py";
548564
RunningPythonProcess.Start();
549565

GH_CPython/GH_CPython/InitFunctions.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace GH_CPython
1010
{
1111
class InitFunctions
1212
{
13-
13+
public bool recall = false;
1414
public string isPythonFloderExists(string dir)
1515
{
1616
string path = "";
@@ -26,10 +26,12 @@ public string isPythonFloderExists(string dir)
2626
return path;
2727
}
2828

29-
public void getPythonInterpretere(string datfile, string defaultFileName, string StartFileName)
29+
public string getPythonInterpretere(string datfile)
3030
{
3131
if (!File.Exists(@datfile))
3232
{
33+
string defaultFileName = "Python.exe";
34+
//MessageBox.Show("Not exists");
3335
if (File.Exists(@"C:\Python27\python.exe")) { defaultFileName = @"C:\Python27\python.exe"; }
3436
else if (File.Exists(@"C:\Anaconda\python.exe")) { defaultFileName = @"C:\Anaconda\python.exe"; }
3537
else if (File.Exists(@"C:\Python34\python.exe")) { defaultFileName = @"C:\Python34\python.exe"; }
@@ -46,18 +48,32 @@ public void getPythonInterpretere(string datfile, string defaultFileName, string
4648
else if (File.Exists(@"C:\Program Files\Python35\python.exe")) { defaultFileName = @"C:\Program Files\Python35\python.exe"; }
4749
else if (File.Exists(@"C:\Program Files\Python36\python.exe")) { defaultFileName = @"C:\Program Files\Python36\python.exe"; }
4850
File.WriteAllText(@datfile, defaultFileName);
49-
locatePython locPy = new locatePython();
50-
locPy.ShowDialog();
51+
52+
return @defaultFileName;
53+
5154
}
5255
else
5356
{
5457
if (File.ReadAllText(@datfile).Trim() != String.Empty)
5558
{
56-
StartFileName = File.ReadAllText(@datfile);
59+
60+
string StartFileName = File.ReadAllText(@datfile);
61+
//MessageBox.Show("Exists at\n"+StartFileName);
62+
return @StartFileName;
5763
}
5864
else
5965
{
60-
MessageBox.Show("Sorry, We can't find Python installed on your machine, If you have already installed it, would you contact Mahmoud Abdlerahman via this e-mail \n [email protected]\n Thanks.");
66+
locatePython locPy = new locatePython();
67+
locPy.ShowDialog();
68+
try
69+
{
70+
string StartFileName = File.ReadAllText(@datfile);
71+
return @StartFileName;
72+
}catch
73+
{
74+
MessageBox.Show("Sorry, We can't find Python installed on your machine, If you have already installed it, would you contact Mahmoud Abdlerahman via this e-mail \n [email protected]\n Thanks.");
75+
return @"Python.exe";
76+
}
6177
}
6278

6379
}

GH_CPython/GH_CPython/Properties/Resources.Designer.cs

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GH_CPython/GH_CPython/Properties/Resources.resx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,37 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121-
<data name="list12" type="System.Resources.ResXFileRef, System.Windows.Forms">
122-
<value>..\Resources\list12.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123-
</data>
124-
<data name="openFile" type="System.Resources.ResXFileRef, System.Windows.Forms">
125-
<value>..\Resources\openFile1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
126-
</data>
127-
<data name="item24" type="System.Resources.ResXFileRef, System.Windows.Forms">
128-
<value>..\Resources\item24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
121+
<data name="tree12" type="System.Resources.ResXFileRef, System.Windows.Forms">
122+
<value>..\Resources\tree12.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
129123
</data>
130124
<data name="data-data-configuration-icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
131125
<value>..\Resources\data-data-configuration-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
132126
</data>
127+
<data name="reset24" type="System.Resources.ResXFileRef, System.Windows.Forms">
128+
<value>..\Resources\reset24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
129+
</data>
130+
<data name="saveIcon24" type="System.Resources.ResXFileRef, System.Windows.Forms">
131+
<value>..\Resources\saveIcon24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
132+
</data>
133+
<data name="pip-icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
134+
<value>..\Resources\pip-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
135+
</data>
133136
<data name="item12" type="System.Resources.ResXFileRef, System.Windows.Forms">
134137
<value>..\Resources\item12.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
135138
</data>
136-
<data name="tree12" type="System.Resources.ResXFileRef, System.Windows.Forms">
137-
<value>..\Resources\tree12.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
139+
<data name="save_as_24" type="System.Resources.ResXFileRef, System.Windows.Forms">
140+
<value>..\Resources\save_as_24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
141+
</data>
142+
<data name="openFile" type="System.Resources.ResXFileRef, System.Windows.Forms">
143+
<value>..\Resources\openFile1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
144+
</data>
145+
<data name="list12" type="System.Resources.ResXFileRef, System.Windows.Forms">
146+
<value>..\Resources\list12.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
147+
</data>
148+
<data name="item24" type="System.Resources.ResXFileRef, System.Windows.Forms">
149+
<value>..\Resources\item24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
150+
</data>
151+
<data name="Python_logo-24" type="System.Resources.ResXFileRef, System.Windows.Forms">
152+
<value>..\Resources\Python_logo-24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
138153
</data>
139154
</root>

GH_CPython/GH_CPython/PythonFileControl.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void writeReadPythonFile(GH_Component ThisComponent,
104104
}
105105
catch (Exception exep)
106106
{
107-
MessageBox.Show(exep.ToString());
107+
//MessageBox.Show(exep.ToString());
108108
}
109109

110110
/// Section 5.
@@ -117,15 +117,15 @@ public void writeReadPythonFile(GH_Component ThisComponent,
117117
thisfileName = ThisComponent.OnPingDocument().DisplayName;
118118
}else
119119
{
120-
thisfilePath = "None";
121-
thisfileName = "None";
120+
thisfilePath = @"C:\GH_CPython";
121+
thisfileName = "unname";
122122
}
123123

124124

125125

126126
string envVars = Resources.SavedPythonFile.initghEnv.Replace(Environment.NewLine, @"\n").Replace("##filePath##", thisfilePath.Replace(@"\", "/"));
127127
envVars = envVars.Replace("##fileName##", thisfileName.Replace("*", ""));
128-
variablesAre = Resources.SavedPythonFile.initVars.Replace("##InitVars##", variablesAre).Replace("##initGHENV##", envVars);
128+
variablesAre = Resources.SavedPythonFile.initVars.Replace("##InitVars##", variablesAre.Replace("'", @"\'")).Replace("##initGHENV##", envVars);
129129
System.IO.File.WriteAllText(path + name + ".py", variablesAre + "\n" + WinForm.PythonCanvas.Text + "\n" + foot);
130130
}
131131

@@ -140,7 +140,6 @@ private string getInputs(GH_Component ThisComponent, IGH_DataAccess DA, int i)
140140
{
141141
if(ThisComponent.Params.Input[i].Access == GH_ParamAccess.item)
142142
{
143-
144143
convetToItem(ThisComponent, i, DA);
145144
IGH_Goo inputObject = null;
146145
DA.GetData(i, ref inputObject);
@@ -224,7 +223,8 @@ private string getInputs(GH_Component ThisComponent, IGH_DataAccess DA, int i)
224223

225224
}
226225
catch(Exception errf)
227-
{ MessageBox.Show(errf.ToString()); }
226+
{ //MessageBox.Show(errf.ToString());
227+
}
228228

229229
return datahere;
230230
}

0 commit comments

Comments
 (0)