This aspect is actually utilized to avoid additional steps. Seems to work alright.
vectors2.dyn (16.3 KB)
This aspect is actually utilized to avoid additional steps. Seems to work alright.
Hello
An example with Cross Product
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
def uniqueVectors(lstVect, tolerance = 0.001):
if len(lstVect) > 0:
vectA =lstVect.pop(0)
otherV = []
for v in lstVect:
if abs(v.Cross(vectA).Z) > tolerance:
otherV.append(v)
return [vectA] + uniqueVectors(otherV)
else:
return []
OUT = uniqueVectors(IN[0])
:o
I fed in my original lines and it works thanks! Can you explain what line 3 (red arrow) means please. I get it’s point at param but I don’t understand the range then -1 then the 0.1:
This only gives me an output of 2 vectors.
Could you give a brief explanation of your script pls?
I get the loops but I don’t understand how you decide what the tolerance is etc.
ok it’s fixed (in my preview post)
when 2 vectors are parallel to the Z component of the product Cross is equal to 0
it is the tolerance for 2 vectors almost parallel (or not), you can replace by this
if abs(v.Cross(vectA).Z) != 0:
for check 2 vectors are strictly no parallel
Ah, I suppose that with Revit tolerance is a good idea?
Any idea where the sweet spot is?
it will depend on your context (need more or less precision)
Line 3 is an extension of Line 2. The -1 and 0.1 are parameters for Flatten and Prune respectively.
when the dot product of two vectors is -1 or 1 the vectors should be parallel - this is likely faster than the cross product … but I have not tested it.