What's new

Scripts "Find Arc Length" and "Find Chord Length" are identical

oldfox

Alibre Super User
Of these two scripts, what is the name of the actual script and can we get the other one?

TKS.
 

ajayre

Alibre Super User
I'm not sure what you are referring to or where you are seeing those script names. Link?

Andy
 

oldfox

Alibre Super User
Andy, I believe they were in the old WizoScript library. I had copied all of the WS scripts to my own directory. That is what I was using. I can't send you a link but I will include the scripts. There are only 2 differences if you do a "File Compare" on them. I deleted line 29 and then moved the leading newline from now line 29 to the end of line 28. Then FC returns "no differences"
****************************************
# FIND CHORD LENGTH

import math

# get current part
P = CurrentPart()
# get a specific 2D sketch
Sk = P.GetSketch("Sketch<1>")

# look for all arcs in sketch
for Fig in Sk.Figures:

# found an arc
if isinstance(Fig, CircularArc):
StartPt = Fig.StartPoint
EndPt = Fig.EndPoint
CenterPt = Fig.Center
Radius = Fig.Radius

# calculate straight-line distance between start and end points
D = math.sqrt(pow(StartPt[0] - EndPt[0], 2) + pow(StartPt[1] - EndPt[1], 2))

# calculate distance along arc between start and end points
Theta = math.acos(1 - ((D * D) / (2 * Radius * Radius)))
Length = (Radius * Theta)
print Length

print "The first four returns from the script are what the script found for arcs."
print "The
print "\nFor ARC < 180 Degrees, MEASURE tool returns 260.720055 mm. CORRECT"
print "For ARC > 180 Degrees, MEASURE tool returns 1383.138526 mm. CORRECT."
pi = 3.141592654
diameter = 660.4
circumference = diameter * pi
halfCircumference = circumference / 2.0
oneThirdCircumference = circumference / 3.0
twoThirdCircumference = circumference / 3.0 * 2.0
fullArc = twoThirdCircumference
segment = 1383.138526 - halfCircumference
print " Circumference = ", diameter * pi
print " 1/3 Circumcerence = ", oneThirdCircumference
print " 2/3 Circumference = ", twoThirdCircumference
print " 1/2 Circumference = %.6f" % halfCircumference
print " Segment = ", twoThirdCircumference - halfCircumference
print "For ARC > 180 Degrees, after substracting 1/2 of the circumference,"
print " SCRIPT returns ", twoThirdCircumference - halfCircumference
print " MEASURE tool returns 345.784631\n"
print "Full arc by SCRIPT = ", twoThirdCircumference
print "Full arc by MEASURE = ", 1383.138526
print "\nSo, bottom line, it looks like the script returns the correct number for arcs greater than 180 degrees. Albeit with rounding errors."
print "Error = ", twoThirdCircumference - 1383.138526, "mm\n"
print "This also verifies, depending on the user's standards, that the measure tool will be good enough to use."

***********************************************

# FIND ARC LENGTH

import math

# get current part
P = CurrentPart()
# get a specific 2D sketch
Sk = P.GetSketch("Sketch<1>")

# look for all arcs in sketch
for Fig in Sk.Figures:

# found an arc
if isinstance(Fig, CircularArc):
StartPt = Fig.StartPoint
EndPt = Fig.EndPoint
CenterPt = Fig.Center
Radius = Fig.Radius

# calculate straight-line distance between start and end points
D = math.sqrt(pow(StartPt[0] - EndPt[0], 2) + pow(StartPt[1] - EndPt[1], 2))

# calculate distance along arc between start and end points
Theta = math.acos(1 - ((D * D) / (2 * Radius * Radius)))
Length = (Radius * Theta)
print Length

print "The first four returns from the script are what the script found for arcs.\n"
print "For ARC < 180 Degrees, MEASURE tool returns 260.720055 mm. CORRECT"
print "For ARC > 180 Degrees, MEASURE tool returns 1383.138526 mm. CORRECT."
pi = 3.141592654
diameter = 660.4
circumference = diameter * pi
halfCircumference = circumference / 2.0
oneThirdCircumference = circumference / 3.0
twoThirdCircumference = circumference / 3.0 * 2.0
fullArc = twoThirdCircumference
segment = 1383.138526 - halfCircumference
print " Circumference = ", diameter * pi
print " 1/3 Circumcerence = ", oneThirdCircumference
print " 2/3 Circumference = ", twoThirdCircumference
print " 1/2 Circumference = %.6f" % halfCircumference
print " Segment = ", twoThirdCircumference - halfCircumference
print "For ARC > 180 Degrees, after substracting 1/2 of the circumference,"
print " SCRIPT returns ", twoThirdCircumference - halfCircumference
print " MEASURE tool returns 345.784631\n"
print "Full arc by SCRIPT = ", twoThirdCircumference
print "Full arc by MEASURE = ", 1383.138526
print "\nSo, bottom line, it looks like the script returns the correct number for arcs greater than 180 degrees. Albeit with rounding errors."
print "Error = ", twoThirdCircumference - 1383.138526, "mm\n"
print "This also verifies, depending on the user's standards, that the measure tool will be good enough to use."
 

ajayre

Alibre Super User
I don't recognize those scripts - don't think I wrote them. What is your question about them?

Andy
 

oldfox

Alibre Super User
OK. I was needing the length of an arc that I was working on and I remembered that these scripts existed. The math is a little over my head so I didn't really look at them in depth. Later upon closer examination and more reading of the "prints" I discovered that I could just use the measure
tool for what I needed. It did indeed work out for me. So I guess that I have no questions any more. I apologize if I wasted your time.

Do you think that Max may be the author?
 
Oldfox -- The Length of an Arc is Ɵ (in Radians the Angular Span of the Arc) X r (the Radius of the Arc). This should not be that hard to implement -- just remember that Radians = Degrees X pi/180.
 
Top