Grasshopper

algorithmic modeling for Rhino

I'm an experienced user but I'm bumping up against the extents of my knowledge on this problem, thought I'd see if there is anyone out there that might be able to help. Apologies in advance for the wall of text.

I have a toolpath, described by a list of planes, that a robot uses to paint an image. After the robot paints an image, I take a picture, which is then analysed with Firefly to generate a bunch of closed curves that describe the outline of what is painted (the preview).

I intend to repeat and transform that initial toolpath to create a composition with the robot and want to use the preview outline to get an idea of what the composition will look like. I cannot simply apply the same transformations to the outline as the toolpath because if I scale the toolpath, I don't want to scale the outline because the brush will not scale and the width of the stroke needs to remain the same.

My solution is to overlay the preview curves and the toolpath and use the Curve CP to get the location of each vertex of the preview curves relative to a parameter of the toolpath curve. Then I transfer those relative positions to the transformed toolpaths and rebuild the outline curves from the verticies. It's not perfect but its closer than simply applying the transformation to the outline curve.

I was able to make this work when I had only one transformed toolpath as a target. I ran into issues when trying to give the script multiple transformed toolpaths, due to the fact that all of the verticies of each of the curves of the preview need to be applied to each one of the toolpath curves. I tried the cross reference and longest list nodes with no successs. This has led me down a rabbit hole of weird tree combinations and path mapping. I have come to a point where it seems to me like it should be working properly, but the results are not right, and the preview curves come out the other end looking like they are zig-zagging back and forth.

I'm looking for suggestions on what might be happening, how to fix it, or even alternate methods for achieving the result I'm looking for. I tend to get locked in on a certain workflow when the solution is simple and I just need to approach it from a different way.  Hopefully someone here will be able to give me that different perspective. I have included the working single target script and the broken multi-target script (disabled) in the same file. I tried to annotate the script as best I could, just ask if you need any clarification. A word of caution - the script is not too heavy and only takes a few seconds to solve on my computer, but I am working from a fairly modern workstation, so I don't have a great idea of how it will perform on a more modest computer.

Thank you!

Views: 316

Attachments:

Replies to This Discussion

Yes! This is awesome.  I am always worried about losing data structure by flattening, but I see you were able to get the correct structure back without relying on match tree or unflatten. 

Thanks a ton, this is very helpful.  I'll try to post some of the results once we get this project underway.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service