Selecting an object within a script

Yep, that is the sagitta of an arc.
The math is simple:
The ideal arc length given the maximum tolerance epsilon:
idealArcLength = 2 * acos(1.0 - (epsilon / radius))

But that may chop your arc up in N equal pieces plus the remaining as a shorter segment.

Chopping the arc in N (rounded up) equal pieces is then:
segmentCount = ceil(arcAngleLength / idealArcLength)

And there is a catch … As always … epsilon / radius can be more than 2.00
In that case the acos() will be invalid because it is less than -1.00.
‘epsilon’ and ‘radius’ are lengths and thus always positive, the acos() can not exceed 1.00

The next limit situation is segmentCount = 1 … Short arc or small radii.
You might set a minimum segmentCount to at least mimic the curved nature.

BTW: Segments are your ‘points’ minus one. :wink:

Regards,
CVH

In arcEntity.setLayerId(this.arcLayer.getId()); you refer to this.arcLayer that you added to an operation.
That operation is not yet applied and the object id will still be invalid.
You must first apply the layer op and retrieve the layer back from the document to know its id … :wink:

Why not use REntity.setLayerName(); instead?

Where REntity is your is your queried arcEntity.

Regards,
CVH

Yeah, that’s why I said:

Also, I’ve found how to change the color of an object without using layer params, so I’ve used that instead, it’s better and doesn’t crash by nature lol

I will still take a look, but people that will use my script told me the N number was totally enoughly good for what they are doing

That is by preference, I look at the wider picture :wink: :

Regards,
CVH

Consider 10 points … 9 segments … DiscretizeArc … ALL >>>

  • A 45 degree arc in nine 5 degree segments.
  • A 4.5 degree arc in nine 1/2 degree segments.
  • An arc with radius 1000 in 9 very coarse segments.
    :wink:

Regards,
CVH

aaah yes

The arc with radius 1000 units chopped in 9 may be a good representation when it is short.
But when it is let’s say 180 degrees then the line segments are about 347.3 units long and the deviation with the original arc or discretization tolerance is about 15.2 units.

It is all about preferences. :wink:

Regards,
CVH

I’ve asked the users and they told me in practice they don’t have much arcs and can handle some extra clicks when arcs are really different.