-
To clarify the concept of parametric modelling I wanted to create a shape governed by a mathematical equation. As an experiment started to reproduce some work I found on the internet to model the Gherkin Tower in London. I started with a simple revolve of a sketch like this: // points on contour
let p0 = [.13 , 0 ]
let p1 = [.20 , .66 ]
let p2 = [.11 , .80 ]
let p3 = [.03 , 1 ]
let p4 = [ 0 , 1 ]
// create a sketch of the contour and close it
let profileGherkin = new Sketch(p0)
.BezierTo([p1,p2,p3,p4])
.LineTo([0,0])
.LineTo(p0)
.End().Face(false)
// revolve the sketch
Translate( [70,0,0],
Rotate( [1,0,0],90,
Revolve(
Scale(180,profileGherkin)
,360,[0,1,0], true, true
)
)
) As I figured that interpolating the points on the spline would not be easy, I searched for an equation to describe the contour. I found a proposal for this equation at https://prezi.com/ag4kjn9i1upt/the-gherkin/ and converted this into the following code: function equationGherkin(x)
{
let pt1 = x*x - 144*x + 5184;
let pt2 = pt1 / 11664;
let pt3 = 1-pt2;
let pt4 = Math.sqrt(pt3);
let y = 28.25 * pt4;
return y
}
// evaluate the function starting a height h=0
let h = 0;
let c0 = [equationGherkin(h),h];
let calculatedGherkin = new Sketch(c0)
for (let hi = 1; hi <= 180; hi+=1)
{
calculatedGherkin.LineTo( [ equationGherkin(hi) , hi])
}
calculatedGherkin.LineTo([0,0])
calculatedGherkin.LineTo(c0);
calculatedGherkin.End();
calculatedGherkin.Face();
// revolve the sketch
Rotate( [1,0,0],90,
Revolve(calculatedGherkin
,360,[0,1,0], true, true
)
) The sketch seems to complete without a problem, but as soon as I feed it to the revolve function I get the error
It seems that by using the form |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Actually, the culprit is the The fix is simply to move |
Beta Was this translation helpful? Give feedback.
-
Thanks, this indeed works. I have to figure out how to explain this properly in the manual. I tried to check what type an object is with the function "typeof" but this simply returns it as "object". |
Beta Was this translation helpful? Give feedback.
Actually, the culprit is the
.Face()
function, which returns aTopoDS_Face
rather than aSketch
object.The fix is simply to move
calculatedGherkin.Face()
from its own line into the Revolve function's signature 👍