ut from an excel form I develop.
If I'm using incorrect terminology please correct, I'm still relatively new to grasshopper and python. Trying to use the .NET COM interop facilities as described in the link below I'm unable to figure out how to update based on the SheetChange event.
http://www.ironpython.info/index.php?title=Interacting_with_Excel#Finding_Stuff
Below is a generic version of what I'm working with that should print the value in cell "A1" of the active worksheet in the active workbook.
Any insight is appreciated.
import clrclr.AddReference("Microsoft.Office.Interop.Excel")
from System.Runtime.InteropServices import Marshal
excel = Marshal.GetActiveObject("Excel.Application")
workbook = excel.ActiveWorkbook
def onSheetChange(): print workbook.ActiveSheet.Range["a1"].Value2
Excel.WorkbookEvents_Event.add_SheetChange(workbook,onSheetChange)
…
Added by Jason Sippel at 7:55pm on November 3, 2016
this common installation problem please find a tested remedy shared by one of the group members:
Comment by Iman Sheikhansari on August 26, 2019 at 8:33amDelete Comment
HiIf you are encountering a problem with rhino 6 versions don't worryFollow these steps.1. Download SYNTACTIC from https://sites.google.com/site/pirouznourian/syntactic-design2. Install it and go to the installation folder, Drag & drop SYNTACTIC(green one) over your grasshopper canvas.3. Close your rhino and reopen it. 4. Type GrasshopperDeveloperSettings5. Tick the Memory load *.GHA assemblies using COFF byte arrays option6. Run grasshopper and enjoy plugin
I hope this helps,
Best regards,
Pirouz
…
g in my own code or in Grasshopper in general is something that I hope to clarify in this discussion.
In the Ladybug+Honeybee community that I frequently develop for, we are often internalizing Geometry in GH files. We have noticed that, whenever this happens, the geometry is internalized at the Rhino model tolerance of the modeler who internalized it. When such an internalized geo GH file is shared with other members of the Ladybug+Honeybee community, this frequently results in a mis-match of internalized GH geometry tolerance and the Rhino model tolerance whoever is opening the shared file.
Many of the components in Ladybug+Honeybee are performing geometric operations with the Rhinocommon SDK and the tolerance is particularly important for these operations. For these operations, we have coded Ladybug+Honeybee to always use the current Rhino model tolerance using scriptcontext.doc.ModelAbsoluteTolerance. As you can imagine, we get a lot of GH files failing because of this mis-match between shared files and I have provided a sample of GH discussions below that have ended in this tolerance madness.
I accept this as a bug in Ladybug+Honeybee if there is some way that I could read the tolerance of all internalized GH geometry instead of the Rhino model absolute tolerance. If someone could show me how to read it, I will replace all tolerance instances of Ladybug+Honeybee with such internalized geometry tolerance (or at least give a warning when there is a mis-match). However, this seemed like it was a bug for the broader GH project as I have noticed that this mis-match causes problems with native GH components. The attached GH file with internalized geometry works if the Rhino model tolerance is set to 0.001 but fails once it is changed to 0.0001.
As such, I wanted to ask if we could at least get a warning message when we open a GH file that tells us when there is a mis-match between internalized geometry and the current Rhino model.
Thanks, as always, and here is that sample of discussions ending in tolerance madness:
http://www.grasshopper3d.com/group/ladybug/forum/topics/radianttempmap-resolution-problem?commentId=2985220%3AComment%3A1144978&groupId=2985220%3AGroup%3A658987
http://www.grasshopper3d.com/group/ladybug/forum/topics/struggled-visualize-the-surface-results?commentId=2985220%3AComment%3A1318461&xg_source=msg_com_gr_forum
http://www.grasshopper3d.com/group/ladybug/forum/topics/open-close-brep-and-indoorviewfactor-issue?commentId=2985220%3AComment%3A1291379&groupId=2985220%3AGroup%3A658987
http://www.grasshopper3d.com/group/ladybug/forum/topics/what-does-it-mean-when-i-have-this-error-message?commentId=2985220%3AComment%3A1233580&groupId=2985220%3AGroup%3A658987…
earch into Pythons exception handling and most of the code now sits inside of:
try:
***My code***
except:
print 'exception message'
Has cleaned up the reactions to the issues quite nicely - actually really liking this language - can see myself using for more tools in the future. Well done on McNeel for choosing this as a scripting language for Rhino.
Anyway - cleaned up code is attached - I've now got two versions, the second one just gets the max plotting area from the plotter and puts it onto the XY work plane so you can check everything will be inside the before plotting/cutting.
I copy these two scripts into a tool bar button:
Left mouse click on the button and it plots, right click gets the plot area.
Cheers all
DK
…
Added by David Kay at 11:07am on November 19, 2017
Calc filesUDP Receiver: Allows the asynchronous reception of User Datagram Protocol messages. Also allows OSC formatted UDP messages. This works on the local machine and across the network.UDP Sender: Allows the asynchronous sending of UDP messages as well as OSC formatted UDP messages.OSC Channel: This component stores the data coming in from one OSC DeviceOSC Dispatch: This component takes a list of OSC devices as inputs and stores their corresponding data.We have a lot of upcoming features almost ready for release including fixes to existing components and new protocols such as MIDI and XML. If there are any protocols you would like us to consider adding, please let us know.We will soon be releasing gHowl to the general public. Until then, if you would like to test out the components, please email us at gHowlcomponents[at]gmail[dot]com. gHowl is currently developed by Giulio Piacentino, Luis E. Fraguada, and Damien Alomar.…
ive an interactive exhibit of sounds and visual effects. It will be a small existing space, or built room. The primary sensors will be a 4x4 grid of piezos in floor modules to emulate a common MIDI control surface. That signal will be generating MIDI notes, as well as manipulating geometry in grasshopper to be projected. I know there are other platforms for audio-video performance like this, but I would like to see how far I can get in Grasshopper.
I have succeeded in calibrating the floor pads to send MIDI messages to a program of my choice (working with Live). At this point there are a couple options as to how to integrate all these operations into Grasshopper, and I wanted to throw this to the community to see if anyone had some early guidance.
1. I assume I am going to have to write the MIDI transmit code into the Firefly Firmata sketch. My question is, will I still be able to drive MIDI via USB in Ableton Live while I read the same data into Grasshopper via USB? Or will my COM ports be hung up?
2. Assuming I can independently achieve the sounds I want in Live, and the video I want in GH... what seems to be the best course for achieving these simultaneously?
…
Added by Joshua Jordan at 8:24pm on November 3, 2013
complicated than it seems as I have an event and a subscriber method receiving data from a serial port.
In the code below, the strings received within myReceivedLines appear when connecting with the serial port (when connecttodevice is true). However they disapear when I launch another command (when homeallis true).
As you recommended in your reply, I have added the field called myReceivedLineswithin the class so that I could use the method String.Add() to all the feedback received and commands sent.
Why does the feedback dispear when a command is sent? Is the string going to myReceivedLine disappearing because they happen within a subscriber method or is it related to the DA.SetDataList() method used to assign myReceivedLinesto the output?
Many thanks!
public class SendToPrintComponent : GH_Component { //Fields List<string> myReceivedLines = new List<string>(); SerialPort port; //subscriber method for the port.DataReceived Event private void DataReceivedHandler(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) { SerialPort sp = (SerialPort)sender; while (sp.BytesToRead > 0) { try { myReceivedLines.Add(sp.ReadLine()); } catch (TimeoutException) { break; } } } protected override void SolveInstance(IGH_DataAccess DA) { //Opening the port if (port == null) { string selectedportname = default(string); DA.GetData(1, ref selectedportname); int selectedbaudrate = default(int); DA.GetData(2, ref selectedbaudrate); //Assigning an object to the field within the SolveInstance method() port = new SerialPort(selectedportname, selectedbaudrate, Parity.None, 8, StopBits.One); //Enables the data terminal ready (dtr) signal during serial communication (handshaking) port.DtrEnable = true; port.WriteTimeout = 500; port.ReadTimeout = 500; } //Event Handling Method bool connecttodevice = default(bool); DA.GetData(3, ref connecttodevice); if (connecttodevice == true) { if (!port.IsOpen) { port.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); DA.SetDataList(0, myReceivedLines); port.Open(); } } else if (port.IsOpen) { port.DataReceived -= new SerialDataReceivedEventHandler(DataReceivedHandler); port.Close(); } if (port.IsOpen) { DA.SetData(1, "Port Open"); } //If the port is open do all the rest if (port.IsOpen) { bool homeall = default(bool); DA.GetData(5, ref homeall); //Home all sends all the axis to the origin if (homeall == true) { port.Write("G28" + "\n"); myReceivedLines.Add("G28" + "\n"); DA.SetDataList(2, myReceivedLines); } } else { DA.SetData(1, "Port Closed"); } }}…
both my plotter/cutter and wide format printer. I had been running the plotter from my main work laptop - a Win10 machine via the plotters USB port. As it turns out you can't get Win XP drivers for this USB connection so I needed another solution.
I tried to use the plotters DB25 serial port connection using an old DB9 to DB25 modem cable I had in my collection = no luck the plotter wouldn't talk. A bit more research and it turns out these plotters need a 'null modem' cross over cable to operate. I found a pic of the correct wiring online and made up my own with some cable and connectors from the local electronics hobby shop.
With this hooked up and using Hyperterminal I was able to fire some codes to the plotter directly and get a response back - winning!
At this point I got my original code working with the 'net use' redirect from LPT1 to COM1.
HOWEVER - being that the plotter was now on a COM port there are a few more interesting things you can do with it - one is being able to read the paper size/cut area from the printer.
So what I needed to to was find a way to send and receive data to/from the plotter using the serial port.
A bit of research into .NET's serial port interface and using a bunch of small pieces of test code I have manged to completely re-jig this driver.
Upgrades include:
- Direct Serial Port comms using Null Modem cable (a USB to serial adaptor + null modem should also work)
- Plot area read from the plotter - a rectangle the size of the plot area is placed on a separate layer and coloured red
- Testing to see if selected plotting curves are both closed and inside of the cutting area - with errors shown and exiting if they are not right.
- After plot 'parking' of the plot head at the end of the cut items + an adjustable offset (currently requires manual resetting of origin on the plotter before for next cut)
Great thing is it is now 100% running within Rhino Python - no DOS command line calls = no flashing up of the CMD wind. Also no temp files needed on the HDD and no limit to number of curves that can be plotted - tested with 200 or so with no issues.
Overall very happy with whole project - have learnt a LOT about Python and .NET interfacing AND ended up with a very handy/useful tool.
Cheers
DK
# This code is a WIP # It plots directly to a DGI Plotter# via the serial port
import System.IO.Ports as Portsimport rhinoscriptsyntax as rsimport time
#Some setup valuescom_port = 'COM1' #change to match plotter port baud_rate = 9600 #change to match plotter settingplotter_step = .025 #mmfinsh_offset = 10 #mm
#Delete old cutting area and cut objectsif rs.IsLayer('Cutting Area'): rs.PurgeLayer('Cutting Area')if rs.IsLayer('Cutting Objects'): rs.PurgeLayer('Cut Objects')
#Setup Serial PortMyport = Ports.SerialPort(com_port)Port_Write = Ports.SerialPort.WriteMyport.BaudRate = baud_rateMyport.ReadTimeout=5000 #5 secsMyport.Close()Myport.Open()
#Setup PlotterPort_Write(Myport, 'PU;PA0,0;IN;\n')Port_Write(Myport, 'SP1;\n')Port_Write(Myport, 'PA;\n')time.sleep(2)
#Read the Paper size from PlotterPort_Write(Myport, 'OH;') #HPGL read limits codetime.sleep(2)
return1 = ''papersize = ''count = 0char_in_buffer = 0chars_in_buffer = Ports.SerialPort.BytesToRead.GetValue(Myport)
if chars_in_buffer == 0: print 'Plotter not ready' Myport.Close() exit()
while (count < chars_in_buffer): return1 = Myport.ReadChar() papersize = papersize + chr(return1) count = count + 1
papersize = papersize.split(",")rect1 = (float(papersize[2])*plotter_step)rect2 = (float(papersize[3])*plotter_step)
print 'Cutting area = ' + str(rect1) + 'x' + str(rect2)
#place cutting area curve on its own layer, make it red and lock itplane = rs.WorldXYPlane()cutting_area = rs.AddRectangle( plane, (rect1), (rect2))rs.AddLayer (name='Cutting Area', color=(255,0,0), visible=True, locked=True, parent=None)rs.ObjectLayer(cutting_area, 'Cutting Area')
#get plotting objects
allCurves = rs.GetObjects("Select curves to plot", rs.filter.curve)
#test to see if these are closed curves - exit if not
for curve in allCurves: test_closed = rs.IsCurveClosed(curve) if test_closed == 0: print "One or move of these curves are not closed" Myport.Close() exit()
#test to see if these are inside cutting area - exit if not
for curve in allCurves: test_inside = rs.PlanarClosedCurveContainment(curve, cutting_area)
if test_inside==0 or test_inside==1: print "One or more of these curves are outside of cut area" Myport.Close() exit()
#All ok - convert to points and send data to printer
rs.AddLayer (name='Cut Objects', color=(0,255,0), visible=False, locked=True, parent=None)
for curve in allCurves: Port_Write(Myport, 'PU;PA;SP1;\n') polyline = rs.ConvertCurveToPolyline(curve,angle_tolerance=5.0, tolerance=0.025, delete_input=False, min_edge_length=0, max_edge_length=0) points = rs.CurveEditPoints(polyline) rs.ObjectLayer(polyline, 'Cut Objects')
# PU to the first point x = points[0][0] y = points[0][1] Port_Write(Myport, 'PU' + str(int(x / plotter_step)) + ',' + str(int(y / plotter_step)) + ';\n') # PD to every subsequent point i = 1 while i < len(points): x = points[i][0] y = points[i][1] Port_Write(Myport, 'PD' + str(int(x / plotter_step)) + ',' + str(int(y / plotter_step)) + ';\n') i += 1
Port_Write(Myport,'PU;\n')
#find the far end of the cutbox = rs.BoundingBox(allCurves)far_end = str(box[1])far_end = far_end.split(",")far_end = far_end[0]far_end = float(far_end)/plotter_stepfar_end = (int(far_end))+ finsh_offsetfar_end = str(far_end)print (far_end)
#return plotter home and close portPort_Write(Myport, 'PU;PA' + far_end + ',0;IN;\n')Port_Write(Myport, 'SP1;\n')Port_Write(Myport, 'PA;\n')Myport.Close()time.sleep(10)…
not seem to manage to download the data... (see picture attached).Djordje, do you have any idea about what I can I do or check to fix this?
I just tried to run the component for a couple of locations and it successfully downloaded the data from opentopography.org:
When did you try to run the component? An hour ago?Can you try again?
Other question, just to be sure, regarding the "origin_", is it the central point that you to get out of the output mesh/surface? And does it need to be the point at the actual point elevation or does it need to be the point projected on the ground floor (as I do in my definition)?
Yes, you are correct about both things: it's the central point and it will lie on the actual terrain (it will be projected to the terrain).The latitude and longitude information from the _location input will be taken to find the origin_ point. Elevation will always be ignored, as elevation is calculated from the elevation of the point laying on the terrain at those particular latitude-longitude coordinates.Please let me know if I did not precisely gave the answer to your questions. Or if I misunderstood your question.We are here to help with any issue.…
' component in K2 works very well, it converged in equilibrium state. But, in K2E, the 'rod' component behave differently so it bend very much that the whole structure became collapsed. I was using the mechanical properties just as the K2E presets has provided.
Model from K2 after Solving
Model from K2E After Solving
I want to do structural analysis on my model using K2E. But, with the whole structure in an equilibrium state as it was reached in K2 component.
Do you have any idea how i should done this?
Should I have any input on the 'Threshold' part of the Solver in order to limit the iteration?
Any help will be much appreciated.
Thank you.…
Added by Irfane to Kangaroo at 7:07pm on February 21, 2018