Deform mesh internal edges without changing the shape

hello lords of GH

I hope your can help me

I have this coloured mesh that essentially represents an structural behaviour. This mesh as a normal mesh is divided in UV rows and columns that i need to keep. What I desperately need is to start deforming the size of this quads and make them smaller in the reddest parts and bigger on the bluest ones but WITHOUT deforming the shape of the pipe.
I am attaching the GH nd Rhino file for you to take a look and some images. Sorry for the vagueness of the one that i painted on. I hope you can understand the idea.

the mesh is a result of the plugg-in MILLIPEDE/ in case you don’t have it installed, I baked the mesh and place it apart so you can still see it there in the gh definition

THANKS SO MUCH IN ADVANCE FOR ANYONE THAT TAKES A LOOK ON THIS AND TRY TO HELP ME !

QUAD DIVISION 2.3dm (94.4 KB)

QUAD DIVISION 2.gh (193.0 KB)

I don’t work with R6 … but … on first sight this appears to be a K2 task: given an Interval of “Force” values (related with the vertices colors [or some other similar rule]) for each vertex find the adjacent vertices and apply the equivalent forces (from vertex to neighbor vertices). Then using some obvious goals (onMesh + plasticAnchors on naked vertices + some kind of quad shape control via diagonals or some other) attempt to relax the mesh

shrinkbycolour2.gh (27.5 KB)
image

I scripted a new goal that shrinks edges by how red the closest point on the input mesh is.

5 Likes

Okay, I realise going a bit off-topic here, but this is pretty fun to play with

shrinkbycolour3.gh (61.4 KB)

17 Likes

animated version

12 Likes

You’re a wizard, Daniel! Thanks for sharing this.

WOOOOOOW
i will open it right now!!! but amazing!!! THANKS SO MUCH

man this is all I NEEDED!!!
<3
when i finish my project I will attach some image to let you know how helpful you were!!!

2 Likes

Would it be possible to make it macOS compatible please?

When I open it, it asks for the KangarooSolver.dll. I downloaded the latest K2 Release from Food4Rhino and placed only the dll into the GH components folder, since Kangaroo is already included somewhere else, but I couldn’t find it.
However, the C# component still raises 2 warnings and an error.
Both warning (CS1701) are about the version of RhinoCommon. The component asks for some kind of runtime policy?
The error (CS0246) is due to the fact that the component can’t find the type or namespace KPlankton. An assembly reference seems to be missing!
I have the Plankton dlls installed inside the components folder.

Hi @diff-arch,
This script isn’t actually using KPlankton at all, I must have left that reference in by mistake.
If you delete line 27 (‘using KPlankton’) in the ShrinkByColour script I think it should work for you.
The other warnings can be ignored.

Hm, line 27 is double RestLength = L * (c.R / 255.0); and I’ve searched the rest of the code and there is no using KPlankton or Kplankton to be found anywhere?

The script editor is split in two!
The top part includes only one line, where the ShrinkByColour class is instantiated and output through A.
The bottom part includes the ShrinkByColour class with all its methods. Nothing more.

try opening your own C# button
and copy the information of Daniel’s
the first part in the top window and the second part in the bottom window and try to run it
i used to have mac and C# codes used to work the same

I see what you mean now.
I’m actually not sure whether it is currently possible to reference the KangarooSolver.dll included with Rhino from a Grasshopper C# script component on a Mac. I think the file is contained in the Rhinoceros.app bundle, but there doesn’t seem to be any way to get to this from the C# script assembly reference manager.
@dan might know if there is a way around this?

it should be possible
Have you checked if you have the Kangaroo 2
if you have the previous one is not gonna work, you need to have the solver of Kangaroo 2 :slight_smile:

Perhaps. App bundles on macOS are just directories with a special .app extension that makes them look/behave like an application. The full path to that solver would likely be:

/Applications/Rhinoceros.app/Contents/Frameworks/RhCore.framework/Versions/A/Resources/ManagedPlugIns/GrasshopperPlugin.rhp/Components/KangarooSolver.dll

1 Like

Thanks Dan.
I can find the dll in the location you say via Finder, but I’m still at a loss how to actually add it in the C# component’s Referenced Assembly>Add window, because there the applications are all greyed out and there seems to be no way to explore their contents.

Oh yeah, that’s probably by design. This dirty-hack might work, as a temporary shim:

  1. Use Finder to rename Rhinoceros.app to Rhinoceros (remove the extension). macOS will ask if you are sure and tell it you want to (this is non-destructive as long as you change it back).
  2. Launch Rhino by going to the /Applications/Contents/MacOS/ folder and double-click the Rhinoceros executable (it should start via Terminal).
  3. Try to reference the assembly at the path above.
  4. When done, quit Rhino, then add the .app extension back to Rhinoceros to turn it back into an app.

Probably not a good long-term solution, so we might need to gin-up a better workaround if this is a frequent need.

PS: In most Finder windows, there’s a “Show Package Contents” item in the right-click menu, but I bet the explorer window in GH lacks that option.

1 Like

Yep, as a long term macOS user, I’m aware of that. Thanks for the absolute path to the dll. Entering this when prompted for an unresolved reference solved the issue I had!

Screenshot 2020-03-02 at 19.38.02

@DanielPiker, @dan, entering the path into the dialogue, instead of the whole app renaming business seems to be a better, less unprofessional idea (for a pro app)!!
Another long-term solution could simply be to make Rhino/Grasshopper aware of where official dependencies (like K2) are located on Windows AND macOS, so that it knows what to chose in each case. Seems to work fine on Windows…

Another curiosity is that the IMG (Import Image) component seems to differ between the Windows and Mac version. I couldn’t get the component from Daniel’s file to run without errors, however when I replaced it, it worked fine.

1 Like

Ah yes, I was forgetting it gives you a chance to resolve it with a file path when you first open. Much easier! (Dan’s workaround did work though) Thanks both

1 Like

Turns out, it doesn’t even work with the latest version from Food4Rhino. :wink: You need the official compiled library that comes bundled with Rhino since release 6.