Grasshopper

algorithmic modeling for Rhino

Hi Everyone

 

I found this this code written by To] on my travels that seems from what i understand to set all Surface UV Directions to match one Guide Surface but i can't get anything but Null outputs in GH.8.0004 Even if use the old C# Legacy Script component. Though it seems Danny has got it to work in an Older GH

 

if (S == null)
return;

Vector3d vec01 = new Vector3d();
Vector3d vec02 = new Vector3d();

if(G == null)
{
A = S.Transpose();
B = true;
}
else
{
//Reparameterize
Interval I = new Interval(0, 1);
S.SetDomain(0, I);
S.SetDomain(1, I);
G.SetDomain(0, I);
G.SetDomain(1, I);
int num1 = 0;
vec01.Set((S.PointAt(0.5, 0.5).X - S.PointAt(0.0, 0.5).X), (S.PointAt(0.5, 0.5).Y - S.PointAt(0.0, 0.5).Y), (S.PointAt(0.5, 0.5).Z - S.PointAt(0.0, 0.5).Z));
vec02.Set((G.PointAt(0.5, 0.5).X - G.PointAt(0.0, 0.5).X), (G.PointAt(0.5, 0.5).Y - G.PointAt(0.0, 0.5).Y), (G.PointAt(0.5, 0.5).Z - G.PointAt(0.0, 0.5).Z));
num1 = vec01.IsParallelTo(vec02, (1.5707963267948966 / 2));

if (num1 == 0)
{
A = S.Transpose();
B = true;
}
else
{
A = S;
B = false;
}
}

Orginal Discussion here...

http://www.grasshopper3d.com/forum/topics/switch-uv-coordinates

 

I need to code to complete a panelling Script for Closed surfaces that bridges the seems but having little Luck. Even with writting workrounds to find only surfaces with different UV directions

 

Thanks In advance

Matt

 

P.s I am not trying to swap the UV or flip the Matrix of a point grid.

Views: 545

Replies to This Discussion

This is the Answer to the code that will make it work that to]  has just posted on the original Discussion..

 

Vector3d vec01 = new Vector3d((S.PointAt(0.5, 0.5).X - S.PointAt(0.0, 0.5).X), (S.PointAt(0.5, 0.5).Y - S.PointAt(0.0, 0.5).Y), (S.PointAt(0.5, 0.5).Z - S.PointAt(0.0, 0.5).Z));
Vector3d vec02 = new Vector3d((G.PointAt(0.5, 0.5).X - G.PointAt(0.0, 0.5).X), (G.PointAt(0.5, 0.5).Y - G.PointAt(0.0, 0.5).Y), (G.PointAt(0.5, 0.5).Z - G.PointAt(0.0, 0.5).Z));

and delete

Vector3d vec01 = new Vector3d();
Vector3d vec02 = new Vector3d();

on top

Though this does not seem to fix my problem as it does not match/change the UV on the Edge Srfs to match the input guide surface created from a subsurface of the orginal Organic Surface. Any thoughts on how to do this either with GH components or Scripting would be great as i am at a loss now.

 

Thank Matt

Hi Matt,

 

I fail to see how Transpose() is going to accomplish this all on it's own. Shouldn't there also be calls to Reverse() to make sure that u and v directions are aligned correctly?

 

I attached a variation of this script that definitely outputs something. It doesn't reparameterize the surfaces, it only flips u and v if this seems to be required.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Hi David

 

I can see now as i better understand the scripts with each fail, that Transpose() is only swaping the U and V if required. Even with the addtional vector infomation added to the script above it does not match the UV's of the guide surface and the target surface as i had thought.

 

  • How would i go about asking the script to also reverse the U and or V if required So that they both match?
  • Should i also be checking the original surface at the  point on the surface that matches in World Space the origin UV of the Plane on the surface thats beeing checked or is it fine to just check it at the centre of a single guide surface like it currently is first script?

 

I would not think i had a need to reparamerize the surfaces as i am looking for the UV and as panels are created from smaller panels that are  defined by domains leaving this at 0.0,0.0,0.0 on the surface to check seems the best idea though i am still very much a newbie to text writen script.

 

I think is something else in the first script that i did not change as was unsure what effect it would have on the following code in the script.

 

Thanks Again

Matt

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