Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5788

How to AddSweep2 from previously defined variables instead of GetObjects()?

$
0
0

@bluekite wrote:

If I have already defined the two rails and cross-sectional curve, what do I need to do to process them so that they can be used as the arguments for the AddSweep2 function? All of the examples in Rhino IronPython assume that its great to manually select objects. I do NOT want to manually select objects.

Here is my current script. How do I make the last line work?

Initializations:

For the inside, short 240 degree spiral...

RodRadius = 0.75
DiagRadius = 0.50
a = DiagRadius * sqrt(pi)
InsideWrapAngle = 240
InsideApproachAngle = 21.05
InsideApproachRadians = radians(InsideApproachAngle)
LineLengthInner = (((a + 2*RodRadius)piInsideWrapAngle/360)* tan(InsideApproachRadians))/2
InsidePitch = 2*LineLengthInner/(240/360)
InsideTwistHeight = a/cos(InsideApproachRadians)

Add the vertical construction line for the spiral.

First, define the top and bottom points...

InsideBottom = rs.AddPoint(0,0,- LineLengthInner)
InsideTop = rs.AddPoint(0,0, LineLengthInner)

test1 = rs.AddLine(InsideBottom, InsideTop)

Add a point at the beginning of the base spiral

pntInsideBottomRailStart = rs.AddPoint(RodRadius,0,-LineLengthInner)

Draw the base spiral for the inside twist.

InsideBottomRail = rs.AddSpiral(InsideBottom, InsideTop,InsidePitch,InsideWrapAngle/360,RodRadius, RodRadius)
obj1 = rs.LastCreatedObjects

Offset the base spiral for the 2nd rail.

InsideTopRail = rs.CopyObject(InsideBottomRail,(0,0,InsideTwistHeight))

Add a point at the beginning of the 2nd rail

pntInsideTopRailStart = rs.CopyObject(pntInsideBottomRailStart,(0,0,InsideTwistHeight))

add a point a the end of the bottom rail

pntInsideBottomRailTop = rs.AddPoint(rs.CurveEndPoint(InsideBottomRail))

add a point a the end of the top rail

pntInsideTopRailTop = rs.AddPoint(rs.CurveEndPoint(InsideTopRail))

Add another rail which will pass through the centroid of the twist crosssection.

InsideCentroidRail = rs.AddSpiral(InsideBottom, InsideTop,InsidePitch,InsideWrapAngle/360,RodRadius + a/2, RodRadius + a/2)

Now move the rail up to the centroid.

rs.MoveObject(InsideCentroidRail, (0,0,InsideTwistHeight/2))

add points at the ends of the centroid rail

pntInsideCentroidRailBottom = rs.AddPoint(rs.CurveStartPoint(InsideCentroidRail))
pntInsideCentroidRailTop = rs.AddPoint(rs.CurveEndPoint(InsideCentroidRail))

Draw a rectangle perpendicular to the rails

InsideTwistStartFrame = rs.PlaneFromFrame(pntInsideBottomRailStart,(1,0,0),(0,0,1))
InsideTwistStartRectangle = rs.AddRectangle(InsideTwistStartFrame,a,InsideTwistHeight)
obj3 = rs.LastCreatedObjects

Zoom in on the figure in all four views simultaneously

rs.ZoomExtents(all=True)

Sweep the rails to create the inner twist.

rs.AddSweep2((InsideBottomRail,InsideTopRail),InsideTwistStartRectangle)

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5788

Trending Articles