Read here for LOTS more of these
shuffle will modify the list and not create another one.
print a but rather
be somehow fixed with the Rhino embedded python engine?
I can imagine huge problems can emerge if the coder is careless.
Just tried this in CPython 2.7:
True = False
True == False
True = not False
True == False
Yes, I read that since at the beginning there were no booleans in python in order to make them backportable they derived True and False from the int() class.
This made them mutable in all Python2 versions. Which was also transferred to IronPython.
I assumed since the C# connection they might have fixed that but unfortunately they didn’t. Perhaps this could be fixed somehow with the embedded engine bind it somehow to .net’s booleans. I don’t know. I’m not familiar with low level programming.
I’m not going to change this behavior.
And I think the Ironpython dev will focus on trying to finish 3.4 before he tries to ´fix’ 2.7
I tried PointAt this time too, but it seems I am doing something wrong.
I have the curve length of 84, then I have a list of numbers between 0 and 84.
When I use PointAt, my points fly everywhere. Do you might know why?
problem derivativeat 07.gh (20.6 KB)
I find your code difficult to follow. It is good practice if you don’t use good descriptive names for the variables to place comments explaining what you’re trying to do.
Up to the part where you remove the duplate values from the list and you sort it everything is clear, but after that I really don’t get what you’re trying to do.
Thank you for saying, I changed it.
I hope it is more clear now.
I have a curve and I want to place points on it between 0 and the MAX length of the curve.
I made values and somehow by using PointAt, the points fly away. I do not yet understand why. Do you might know why my points are not on that curve?
problem derivativeat 08.gh (27.0 KB)
Point at takes parameter not distance on the curve
One of the components here does what you want.
It will be a good test to see if it works with multiple length values instead of the slider. I do not remember how I intended it to work
I can fix it.
I need python, does it not exist in python?
EDIT: never mind, I found it from a former post
You’ll have to normalize the length if I remember correctly, keep that in mind
No it seems it can be used without normalizing the length.
You could also, you know, look up the documentation:
You’re logic is wrong, @ForestOwl! You need to remap your desired distance for each curve from the curve length domain to the curve domain.
Let’s say your desired, random distance for a point on the curve is 2.5, and the domain of the curve is (3.5, 5.0), whereas its length domain is (0.0, 84.856). At the moment, you try to create a point at the curve parameter 2.5, which doesn’t exist. This makes your point appear somewhere else.
Instead, you simply remap your distance to the curve domain. For this example, that should be a curve parameter of 3.544… that fits on your curve, since it’s included in the curve domain!
import Rhino.Geometry as rg import random random.seed(2) def fit(value, source_domain, target_domain): """Fits a number between a target domain that is relative to a number in the source domain. Args: value: number to be fitted source_domain: tuple containing the domain start and end target_domain: tuple containing the domain start and end Returns: The refitted value, or None, if the initial value is outside the source domain. """ if (value < source_domain) or (value > source_domain): return else: source_range = source_domain - source_domain if source_range == 0: fitted_value = target_domain else: target_range = target_domain - target_domain fitted_value = (((value - source_domain) * target_range) / source_range) + target_domain return fitted_value curr_plane = Planes curr_crv = Curves min_dist, max_dist = DistInterval # Get the curve length crv_len = curr_crv.GetLength() # Get the curve domain crv_dom = curr_crv.Domain curr_dist = 0.0 # current desired distance crv_parameters =  # curve parameters div_pts =  # curve division points while curr_dist < crv_len: # Remap the desired distance to the curve domain crv_param = fit(curr_dist, (0.0, crv_len), crv_dom) # Check if curve parameter hasn't been visited yet if crv_param not in crv_parameters: # Get the curve point for the curve parameter pt = curr_crv.PointAt(crv_param) # Add the curve point to the division points list div_pts.append(pt) # Add the curve parameter to the curve parameters list as history entry crv_parameters.append(crv_param) # Randomly increment the current desired distance curr_dist += random.randint(min_dist, max_dist) # --- OUTPUTS a = div_pts
problem derivativeat 08.gh (16.4 KB)
No, this wouldn’t work either! When normalising the curve domain or curve length, you still have to remap your distance to the normalised domain, when it’s not between 0.0 and 1.0.