duino code generator works fine, but when exporting, it doesn't seem to work? Could some one please tell me what is FFcasts.h, and if that could be effecting my code? Or if there is anything wrong in general with the export.
{0}
0. /* Firefly Code Generator by Andy Payne Copyright 2011 All Rights Reserved Code Generated on 03/04/2013 20:46:37 Special thanks to Panagiotis Michalatos. For more information visit: www.fireflyexperiments.com */
#include "FFCasts.h" #include <Servo.h>
//******************* Begin Function Definitions *******************
//Remap Number Function: Remap a value into a new numeric domain. double Remap_Numbers(double x, Interval _in, Interval _out) { return (x - _in.t0) * (_out.t1 - _out.t0) / (_in.t1 - _in.t0) + _out.t0; }
//Constrain Function: Constrains a number to a specific numeric range. double Constrain(double _v1, Interval _in){ double _min, _max, result; if (_in.t0 < _in.t1){ _min = _in.t0; _max = _in.t1; }else{ _min = _in.t1; _max = _in.t0; } if (_v1 < _min){ result = _min; }else if (_v1 > _max){ result = _max; }else{ result = _v1; }return result; }
double Smoothing_pval_0 = 0;
//Smoothing Function: Returns a smoothed value that is the sum of the weighted average of the previous observations and the current value. double Smoothing_Temporal(double _v1, double _sf, double *_pval){ *_pval *= _sf; return *_pval += _v1 *(double)(1.0 - _sf); }
//******************** End Function Definitions ********************
Servo servo9;
void setup() { servo9.attach(9); }
void loop() { int APin0 = analogRead(0); servo9.write(Smoothing_Temporal(Remap_Numbers(Constrain(APin0,Interval(10,130)),Interval(10,130),Interval(0,180)),5.0, &Smoothing_pval_0)); }
…
o's command 'InterpCrv' manually(white line).
We had one need to make the rhino-InterpCrv curve in grasshopper.
One thing I've tried is using a python script to emulate the rhino-InterpCrv, but didn't get any results,since I didn't know how to define the arrCV1 and arrCVn1 when using the 'AddInterpCurve (knotstyle=1/2)'
knotstyle from the rhino IronPython help
knotstyle
Optional. Number. The knot style to use, and whether the curve should be periodic. If omitted, uniform knots (0) are created.
Value
Description
0
Uniform knots. Parameter spacing between consecutive knots is 1.0.
1
Chord length spacing. Requires dblDegree = 3 with arrCV1 and arrCVn1 specified.
2
Sqrt (chord length). Requires dblDegree = 3 with arrCV1 and arrCVn1 specified.
3
Periodic with uniform spacing.
4
Periodic with chord length spacing. Requires an odd degree value.
5
Periodic with sqrt (chord length) spacing. Requires an odd degree value.
did anyone tried to create a curve like native Rhino from script? or, is there a another GH component that is suitable for smooth curves?
I guess a alternative way will be using rs.Command('InterpCrv'), but wanted to know if there will be a smarter way...…
思った感じになりません。
balls の代わりにplanarカーブを直接入れてみましたがエラーが出ます。
ファンクションにしてみたところ、forループので作った数値が反映されていません。
ファンクションのインスタンス?を出力していないと思い上記のようにしましたがエラーが出てしまいます。
以上の事から自分の認識が正しいのかよくわからなくなりました・・・
python自体の深いところをわかっているわけではないので余計こんがらがりました。
そこで、for b in ballsはどのような条件または使い方であれば使えるのでしょうか?
そして、上記のように別のオブジェクトに対しての使い方はどのようにすればできるのでしょうか?
2:同じファンクション内のdist = rs.Distance(self.pos,b.pos)についてですが
この文章も for b in balls によってbはBallのインスタンスであると定義?されたためb.posがbの位置であると分かるのでしょうか?
pythonは定義しなくても動いてしまうのでどのような時に使えるのか文章見ただけではよくわかりません・・・
大変細かいことかもしれませんが、よりpythonをしっかりと理解するためにも、どなたかわかる方ご教授いただけると幸いです。…
0.1 Webinar introduction0.2 Installation of Ladybug for Grasshopper (+Rhino)0.3 Getting started with Ladybug for Grasshopper (+Rhino)0.4 Introduction to Environmental Design Analysis - process and methodology_STEP 1 CLIMATE ANALYSIS (NO MODEL)1.0 Introduction to Climate Analysis1.1 Finding and importing weather data file1.2 Sun Path1.3 Temperature chart1.4 Humidity chart1.5 Wind Rose1.6 Comfort Analysis based on weather data1.7 Psychrometric Chart1.8 Bioclimactic Chart1.9 Customizing Analysis Period and Charts_STEP 2A ANALYSIS OF EXISTING URBAN SPACES (WITH MODEL)2a.0 Introduction to Analysis of existing Urban Spaces2a.1 Import Context models from Rhino2a.2 Radiation Rose2a.3 Solar Fan / Envelope_STEP 2B ANALYSIS OF NEW URBAN SPACES / DEVELOPMENT (WITH MODEL)2b.0 Introduction to Analysis of new Urban Spaces2b.1 Import new Urban Buildings and/or Elements from Rhino2b.2 Parametric Grasshopper models 2b.3 Radiation Rose-------------------DANIEL NIELSENThe Danish architect Daniel Nielsen has a broad experience with Architectural Sustainability and the integration of parametric 3D modeling and simulation tools into the process. He have worked on projects at various scales - from buildings to planning, and have been involved in research and education programs at The Royal Danish Academy of Fine Arts and Technical University of Denmark.…
feed back:
Last year a group of graduate students at McGill did this: http://web.farmmresearch.com/pavilion/
I was a member of this group and was one of the people involved in the creation of the grasshopper file (see screen shot at bottom of post - please excuse the spelling errors if you find them). There were effectively no drawings, only the grasshopper script, a bit of post processing in soildworks, cnc fabrication, and hand assembly using labels etched in at the time of cnc fabrication.
As you can see from the screen shot the GH file is a hellish nightmare, right on the edge of the memory limit of rhino 4 (which we had to use because of a minor difference in the way rhino 5-GH handled sweeping), and, towards the end, it took about 15 minutes of computer time just to get to the point were we could work on the script because of all the calculations need in the stack.
Here is a list of things that would have really helped us:
1. More programming experience. i had a bit, most others didn't. David can't help to much with this in a direct way.
2. Clusters: at the time we started clusters didn't work well, by the time they did we were almost done - oh well. I do have some ideas about how it would be nifty for clusters to have version control so that the master assembly could revert thinks that cause other things to break. - I'm sure this can be done manually right now but i have never tried it. could GH be plumbed into something like svn?
3. Concurrent editing - Like a video game. It would, i imagine, require some sort of cloudy file storage and server solution or something but there were MANY hours were 3 or more people were crowded around one computer trying to solve a problem. Alowing everyone to have there own view of the file that stayed in sync would just have been more comfortable...
4. Progress bars and the UI and Display running in a separate thread from the solver. Davids addition of esc to allow us two sometimes save ourselves if we connected a wire wrong but often not. It would be cool to be able to interact with the grasshopper file right away and sill know that the solver was working away (especially when a single run of the file took 15 minutes). Progress bars would be nice on any component taking more than a second or two to run (which was the case with many of our components - especially the ones that we wrote ourselves) but they only make sense to add after the threads for the solver and the UI have been separated.
So, anyone else done a really huge GH file? Thoughts?
…
Added by Dieter Toews at 7:43pm on September 3, 2013
ed pygeoj.py It must be in your script's folder by Karim Bahgat https://github.com/karimbahgat ----------------------------------- TODO : use something like : https://github.com/karimbahgat/PyCRS ----------------------------------- Copyright (c) 2015, Guillaume Meunier <alliages@gmail.com> GEOJSON_export is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. GEOJSON_export is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. GNU General Public License <http://www.gnu.org/licenses/>. @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> - Args: path: path where to export filename: filename of your JSON without its extension (GEOJSON added) using_keys: which key attributes to export, 'id' by default s_names: values of 'id' key s_keys: normally each surfaces user attributes' keys s_values: normally each surfaces user attributes' values s_vertex: vertex of each surfaces run: do the export Returns: out: various information coordiantes: coordinates in JSON format properties: properties in JSON format
VER 1.3
few bugfixes
31_5_2016
VER 1.2
create multipolygon (with holes and multiple objects)
23_3_2016
-----
VER 1.1
resolved problem with geometry check in qgis by closing completely polygon
5_1_2016
---
VER 1.0
3_12_2015
In Extra category
code is here : https://gist.github.com/Alliages/8dbfce7cdd24383342b0
…
t file** - ply file with just x,y,z locations. I got it from a 3d scanner. Here is how first few lines of file looks like - ply format ascii 1.0 comment VCGLIB generated element vertex 6183 property float x property float y property float z end_header -32.3271 -43.9859 11.5124 -32.0631 -43.983 11.4945 12.9266 -44.4913 28.2031 13.1701 -44.4918 28.2568 13.4138 -44.4892 28.2531 13.6581 -44.4834 28.1941 13.9012 -44.4851 28.2684 ... ... ... In case you need the data - please email me on **nisha.m234@gmail.com**. **Algorithm:** I am trying to find principal curvatures for extracting the ridges and valleys. The steps I am following is: 1. Take a point x 2. Find its k nearest neighbors. I used k from 3 to 20. 3. average the k nearest neighbors => gives (_x, _y, _z) 4. compute covariance matrix 5. Now I take eigen values and eigen vectors of this covariance matrix 6. I get u, v and n here from eigen vectors. u is a vector corresponding to largest eigen value v corresponding to 2nd largest n is 3rd smallest vector corresponding to smallest eigen value 7. Then for transforming the point(x,y,z) I compute matrix T T = [ui ] [u ] [x - _x] [vi ] = [v ] x [y - _y] [ni ] [n ] [z - _z] 8. for each i of the k nearest neighbors:<br> [ n1 ] [u1*u1 u1*v1 v1*v1] [ a ]<br> [ n2 ] = [u2*u2 u2*v2 v2*v2] [ b ] <br> [... ] [ ... ... ... ] [ c ] <br> [ nk ] [uk*uk uk*vk vk*vk]<br> Solve this for a, b and c with least squares 9. this equations will give me a,b,c 10. now I compute eigen values of matrix [a b b a ] 11. This will give me 2 eigen values. one is Kmin and another Kmax. **My Problem:** The output is no where close to finding the correct Ridges and Valleys. I am totally Stuck and frustrated. I am not sure where exactly I am getting it wrong. I think the normal's are not computed correctly. But I am not sure. I am very new to graphics programming and so this maths, normals, shaders go way above my head. Any help will be appreciated. **PLEASE PLEASE HELP!!** **Resources:** I am using Visual Studio 2010 + Eigen Library + ANN Library. **Other Options used** I tried using MeshLab. I used ball pivoting triangles remeshing in MeshLab and then applied the polkadot3d shader. If correctly identifies the ridges and valleys. But I am not able to code it. **My Function:** //the function outputs to ply file void getEigen() { int nPts; // actual number of data points ANNpointArray dataPts; // data points ANNpoint queryPt; // query point ANNidxArray nnIdx;// near neighbor indices ANNdistArray dists; // near neighbor distances ANNkd_tree* kdTree; // search structure //for k = 25 and esp = 2, seems to got few ridges queryPt = annAllocPt(dim); // allocate query point dataPts = annAllocPts(maxPts, dim); // allocate data points nnIdx = new ANNidx[k]; // allocate near neigh indices dists = new ANNdist[k]; // allocate near neighbor dists nPts = 0; // read data points ifstream dataStream; dataStream.open(inputFile, ios::in);// open data file dataIn = &dataStream; ifstream queryStream; queryStream.open("input/query.
pts", ios::in);// open data file queryIn = &queryStream; while (nPts < maxPts && readPt(*dataIn, dataPts[nPts])) nPts++; kdTree = new ANNkd_tree( // build search structure dataPts, // the data points nPts, // number of points dim); // dimension of space while (readPt(*queryIn, queryPt)) // read query points { kdTree->annkSearch( // search queryPt, // query point k, // number of near neighbors nnIdx, // nearest neighbors (returned) dists, // distance (returned) eps); // error bound double x = queryPt[0]; double y = queryPt[1]; double z = queryPt[2]; double _x = 0.0; double _y = 0.0; double _z = 0.0; #pragma region Compute covariance matrix for (int i = 0; i < k; i++) { _x += dataPts[nnIdx[i]][0]; _y += dataPts[nnIdx[i]][1]; _z += dataPts[nnIdx[i]][2]; } _x = _x/k; _y = _y/k; _z = _z/k; double A[3][3] = {0,0,0,0,0,0,0,0,0}; for (int i = 0; i < k; i++) { double X = dataPts[nnIdx[i]][0]; double Y = dataPts[nnIdx[i]][1]; double Z = dataPts[nnIdx[i]][2]; A[0][0] += (X-_x) * (X-_x); A[0][1] += (X-_x) * (Y-_y); A[0][2] += (X-_x) * (Z-_z); A[1][0] += (Y-_y) * (X-_x); A[1][1] += (Y-_y) * (Y-_y); A[1][2] += (Y-_y) * (Z-_z); A[2][0] += (Z-_z) * (X-_x); A[2][1] += (Z-_z) * (Y-_y); A[2][2] += (Z-_z) * (Z-_z); } MatrixXd C(3,3); C <<A[0][0]/k, A[0][1]/k, A[0][2]/k, A[1][0]/k, A[1][1]/k, A[1][2]/k, A[2][0]/k, A[2][1]/k, A[2][2]/k; #pragma endregion EigenSolver<MatrixXd> es(C); MatrixXd Eval = es.eigenvalues().real().asDiagonal(); MatrixXd Evec = es.eigenvectors().real(); MatrixXd u,v,n; double a = Eval.row(0).col(0).value(); double b = Eval.row(1).col(1).value(); double c = Eval.row(2).col(2).value(); #pragma region SET U V N if(a>b && a>c) { u = Evec.row(0); if(b>c) { v = Eval.row(1); n = Eval.row(2);} else { v = Eval.row(2); n = Eval.row(1);} } else if(b>a && b>c) { u = Evec.row(1); if(a>c) { v = Eval.row(0); n = Eval.row(2);} else { v = Eval.row(2); n = Eval.row(0);} } else { u = Eval.row(2); if(a>b) { v = Eval.row(0); n = Eval.row(1);} else { v = Eval.row(1); n = Eval.row(0);} } #pragma endregion MatrixXd O(3,3); O <<u, v, n; MatrixXd UV(k,3); VectorXd N(k,1); for( int i=0; i<k; i++) { double x = dataPts[nnIdx[i]][0];; double y = dataPts[nnIdx[i]][1];; double z = dataPts[nnIdx[i]][2];; MatrixXd X(3,1); X << x-_x, y-_y, z-_z; MatrixXd T = O * X; double ui = T.row(0).col(0).value(); double vi = T.row(1).col(0).value(); double ni = T.row(2).col(0).value(); UV.row(i) << ui * ui, ui * vi, vi * vi; N.row(i) << ni; } Vector3d S = UV.colPivHouseholderQr().solve(N); MatrixXd II(2,2); II << S.row(0).value(), S.row(1).value(), S.row(1).value(), S.row(2).value(); EigenSolver<MatrixXd> es2(II); MatrixXd Eval2 = es2.eigenvalues().real().asDiagonal(); MatrixXd Evec2 = es2.eigenvectors().real(); double kmin, kmax; if(Eval2.row(0).col(0).value() < Eval2.row(1).col(1).value()) { kmin = Eval2.row(0).col(0).value(); kmax = Eval2.row(1).col(1).value(); } else { kmax = Eval2.row(0).col(0).value(); kmin = Eval2.row(1).col(1).value(); } double thresh = 0.0020078; if (kmin < thresh && kmax > thresh ) cout << x << " " << y << " " << z << " " << 255 << " " << 0 << " " << 0 << endl; else cout << x << " " << y << " " << z << " " << 255 << " " << 255 << " " << 255 << endl; } delete [] nnIdx; delete [] dists; delete kdTree; annClose(); } Thanks, NISHA…
ers can be applied from the right click Context Menu of either a component's input or output parameters. With the exception of <Principal> and <Degrees> they work exactly like their corresponding Grasshopper Component. When a I/O Modifier is applied to a parameter a visual Tag (icon) is displayed. If you hover over a Tag a tool tip will be displayed showing what it is and what it does.
The full list of these Tags:
1) Principal
An input with the Principal Icon is designated the principal input of a component for the purposes of path assignment.
For example:
2) Reverse
The Reverse I/O Modifier will reverse the order of a list (or lists in a multiple path structure)
3) Flatten
The Flatten I/O Modifier will reduce a multi-path tree down to a single list on the {0} path
4) Graft
The Graft I/O Modifier will create a new branch for each individual item in a list (or lists)
5) Simplify
The Simplify I/O Modifier will remove the overlap shared amongst all branches. [Note that a single branch does not share any overlap with anything else.]
6) Degrees
The Degrees Input Modifier indicates that the numbers received are actually measured in Degrees rather than Radians. Think of it more like a preference setting for each angle input on a Grasshopper Component that state you prefer to work in Degrees. There is no Output option as this is only available on Angle Inputs.
7) Expression
The Expression I/O Modifier allows you change the input value by evaluating an expression such as -x/2 which will have the input and make it negative. If you hover over the Tag a tool tip will be displayed with the expression. Since the release of GH version 0.9.0068 all I/O Expression Modifiers use "x" instead of the nickname of the parameter.
8) Reparameterize
The Reparameterize I/O Modifier will only work on lines, curves and surfaces forcing the domains of all geometry to the [0.0 to 1.0] range.
9) Invert
The Invert Input Modifier works in a similar way to a Not Gate in Boolean Logic negating the input. A good example of when to use this is on [Cull Pattern] where you wish to invert the logic to get the opposite results. There is no Output option as this is only available on Boolean Inputs.
…
.com/forum/topics/use-pythoneditor-to-run?commentId=2985220%3AComment%3A138538
For now I am considering a simple test case in which a set of sliders are added together into a GH_number component called "output":
I am finding that from the Rhino Python Editor it is definitely possible to change the slider values and retrieve results in a loop. Below I copied the code that runs from the Rhino Python Editor, where I simply change the slider value of the slider with Nickname "Number Slider1" from 0 to 2. (note that grasshopper and the testfile are already open in this example)
This script prints out the following results as expected:
Slider value: 0.0Result value: 1.154Slider value: 1.0Result value: 2.154Slider value: 2.0Result value: 3.154
However using the exact same code in a GHPython component within Grasshopper the Grasshopper Python Script Editor's console reads:
Slider value: 2.0Result value: 3.154Slider value: 2.0Result value: 3.154Slider value: 2.0Result value: 3.154
It seems that the solver doesn't recompute during each iteration but just retrieves the final state of my script.
So basically I have been trying to trigger a 'runsolver' command inside my loop. I tried using the methods available trough the RhinoScript interface, as David describes here.
http://www.grasshopper3d.com/forum/topics/open-a-gh-automatically
I could create a loop looking like this:
But running this in the Grasshopper Component crashes Rhino. I have also tried this by Disabling the solver first using the DisableSolver() method. This does disable the solver but still Rhino crashes. Also I used the ExpireSolution(True) method on the slider object like:
However in this case I don't get any different results.
So I guess my question is simple:
Is there a way to recompute the solver after a slider change inside a GHPython script component during a loop?
Any suggestions, or references would be greatly appreciated!
(FYI: I am using Rhino5x64 and Grasshopper Version 0.9.0014, attached is the script I used both in the Rhino Python Editor and the GHPython component and the grasshopper file)…