19 May, 2019

## Circle Curve Divide

In this post we make a variation of Points along curve by max spacing, to generate division points and axes along a circle curve in three ways: by angle, instances and angle-instances. This spacing can be particularly useful as more flexible polar assembly pattern.
The circular division is displayed using an action and a reaction, but the logic can also be captured with a knowledge pattern (explained in the previous posts).

### Using an action

For each use of the action, all inputs and parameters need re-assignment.

### Using a reaction

However using the reaction, inputs and parameters need only be set once within the script. Additionally, whenever the value of a parameter changes, it triggers the script to run again, consequently updating the output.

using the knowledge pattern we have 3 main benefits. Firstly, the result is automatically updated, removing manual work. The geometries (points or axes) can be used with the assembly pattern, without losing the links. Lastly, the knowledge pattern can be embedded within Powercopies, thus reused in other models.

### Point to note:

The axis will always be created under the in-work object, which does not take into consideration which Geoset is set into the script. Despite using the method SetWorkContext(Geoset), setting the active object in EKL is not possible.

//Declare variables
let crvLength (LENGTH)
let crv (Circle)
let srf (Surface)
let extPt, pt, ctPt, pjPt, ptDir(Point)
let tnLine, yLine, prjLine (Line)
let ptAxis (AxisSystem)
let normalDir, yDir, pjDir (Direction)
let count, i, instDiv (Integer)
let ptName, axName, divType (String)
let delList, geoList (List)
let delItem(Feature)
let geoDest, geoPt, geoAx, geoItem (OpenBodyFeature)

//set the inputs
set crv = CircleCurve
set divType = DivisionType
set stAngle = StartAngle
set divAngle = AngleDivision
set instDiv = InstancesDivision
set geoDest = GeoDestination
set srf = ReferencePlane

//Clean the destination
geoList = geoDest.Query("OpenBodyFeature", "")
if geoList.Size() > 0
{
for geoItem inside geoList
{
delList = geoItem.Query("Feature", "")
if delList.Size() > 0
{
for delItem inside delList
{
delItem.Delete()
}
}
else
{
break
}
}
}

//Define the division values for each typology
if divType == "Angle"
{
count = floor(360/Angle)
stRatio = StartAngle/360
}
if divType == "Instances"
{
count = (Instances-1)
stRatio = 0
}
if divType == "Angle&Instances"
{
count = (Instances-1)
stRatio = StartAngle/360
}

//Define the extremity point projecting the center point along Ydir
ctPt = center(crv)
ptDir = pointonsurface(srf, pt, direction(0mm, 1mm, 0mm), 1mm)
prjLine = line(ctPt, ptDir)
pjDir = direction(prjLine)
pjPt = project(ctPt, crv, pjDir)
crvLength = length(crv)

//Create the GeoSets to contain points and axes
geoPt = new("OpenBodyFeature", "Points", geoDest)
geoAx = new("OpenBodyFeature", "Axes", geoDest)

//Division creating points and axes
i = 0
for i while i <= count
{
ptName = "Pt-"+i
axName = "Ax-"+i
pt = new("Point", ptName, geoPt )
pt = pointoncurveRatio(crv, pjPt , stRatio, False)
tnLine = linetangent(crv, pt, 0mm, 1mm, False)  //Axes will be tanget to the curve
normalDir = direction(tnLine)
yLine = line(pt, ctPt)
yDir = direction(yLine)
ptAxis = new("AxisSystem", axName, geoAx)
ptAxis = axisSystem(pt, normalDir, yDir)