Weird "polyextrude flip" on negative curve values?

   1705   3   1
User Avatar
Member
6 posts
Joined: Feb. 2020
Offline
I am thinking I am missing the point so I am looking for some insides on this matter, so any help I really do appreciate.

The scenario:
1. The user should be able to create a street with just a curve input.
2. the curve is wired to a polyexpand followed by a polyextrude.

The issue:
when a point in the curve is changed from a positive value to a negative the vertex sort different and polyextrude flips its orientation.

I can remove the flip by toggle "Reverse" on the curve wich changes the vertex order BUT this has to be done manually and therefore is not an option.


The question:
1. How can I write an expression to set the curve flip automatically ?
2. Is there a better approach in general?

The goal:
the user should be able to create any curve an the polyexpand, polyextrude always is building upwards.

Thanks for any help!






what is the correct approach to ALWAYS have positive upwards direction of the polyextrude no matter what direction the input curve has?
Is there a way to hardcode the direction or set an expression?

Attachments:
polyextrude_flip.hiplc (117.2 KB)
a.jpg (513.9 KB)
b.jpg (520.0 KB)
c.jpg (507.0 KB)

User Avatar
Member
236 posts
Joined: March 2015
Offline
Hi, I've attached a screenshot and hip file that shows one method...

Assuming that the curve will be drawn from above, you can group primitives facing down and reverse that group before the extrude.

Rob

Attachments:
polyextrude_flip_RS.jpg (190.1 KB)
polyextrude_flip_RS.hiplc (87.5 KB)

User Avatar
Member
142 posts
Joined: Aug. 2009
Offline
This Trick I learned in Asia Forums
int previousPt = (@ptnum - 1 + @numpt) % @numpt;
 int currentPt = @ptnum;
 int nextPt = (@ptnum + 1) % @numpt;
 
 
 vector previousDir = point(geoself(), "P", previousPt) - point(geoself(), "P", currentPt);
 previousDir = normalize(previousDir);
 
 
 vector nextDir = point(geoself(), "P", nextPt) - point(geoself(), "P", currentPt);
 nextDir = normalize(nextDir);    
     

 float radian = acos(dot(previousDir, nextDir));
 

 vector centerDir = normalize(nextDir + previousDir);

 if (cross(nextDir, previousDir).y <= 0) {
     centerDir = -centerDir; 
 } 
 

 float r = chf("radius"); 
 float vectorLength = r / sin(radian / 2.0);
 

 v@MoveVector = vectorLength * centerDir;

@P += v@MoveVector;
than Skin on any Line polygon
Maybe It Helps
User Avatar
Member
6 posts
Joined: Feb. 2020
Offline
Thanks alot, I will Test and report Back...nevertheless, I think this should be a checkbox inside the polyextrude
  • Quick Links