Python question and different results Win vs Mac


#1

I have a basic script that draws a poly line through points, then revolves to make a closed poly surface.

Question 1:

Is there a more efficient way to do the points, like a list for example? If so. is it possible to make 3-4 lists of different points and chose one of them to revolve in the same script?

import rhinoscriptsyntax as rs

pt1 = (0,0,0)
pt2 = (-3.6,0,0)
pt3 = (-3.6,0,1.2)
pt4 = (-2.4,0,1.2)
pt5 = (-2.4,0,3.8)
pt6 = (-6,0,3.8)
pt7 = (-6,0,5.5)
pt8 = (-5.3,0,5.5)
pt9 = (-5.3,0,4.5)
pt10 = (0,0,4.5)

curve = rs.AddPolyline((pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8, pt9, pt10))

layer01 = rs.AddLayer("pop outline")

rs.ObjectLayer(curve, layer01)
if not rs.IsLayer(layer01):
    rs.AddLayer(layer01, (0,127,0))

polysurface = rs.AddRevSrf( curve, ((0,0,0), (0,0,1)) )

layer02 = rs.AddLayer("pop")

rs.ObjectLayer(polysurface, layer02)
if not rs.IsLayer(layer02):
    rs.AddLayer(layer02, (0,0,0))

rs.LayerVisible(layer01, 0)

rs.PurgeLayer("pop outline")

Question 2: I get a different object when I run this script on Windows than when I run it on my Mac. Windows gives my a polysurface, which is what I would expect.

While on my Mac I get a single surface. I haven’t run this in a while but it seems to me it used to be a polysurface on my Mac as well.

popInclear.py (666 Bytes)

Plug-Windows.3dm (131.0 KB)
Plug-Mac.3dm (125.2 KB)

Thanks, «Randy


(Wim Dekeyser) #2

What is CreaseSplitting set to on your Mac?


#3

Where would i find that, I can run the command, but a quick look through Preferences doesn’t show that I have the ability to change that. I am still looking :slight_smile:

In Document options all I see is this.

If I run CreaseSplitting, I cannot select the model.


(Wim Dekeyser) #4

CreaseSplitting is a global option and will affect operations that are done after it was set. So this won’t take geometry as input and change it. When you run the command you should be able to see if it is enabled or disabled (still haven’t gotten around installing my Mac license on my wife’s mac).

To fix existing geometry, run the DivideAlongCreases command with SplitAtTangents=Yes.

EDIT: but then … these are obviously not tangent edges… so I’m not sure if that will do the trick.


#5

Also SplitAtKinks=Yes


#6

So, once I run the CreaseSplitting command and check Split Along Creases, then rerun the Python script, it works as expected. First test on the left.

Why would this be happening in the first place? Should one run Crease Splitting as a macro on startup?

I was doing a sweep2 for a ring shank the other day with a rectangle (conic corners) for cross-section and it gave me a single surface. I wasn’t expecting that either.

@Helvetosaur any suggestions for my first question, or should I just make a copy of this one and adjust the point for my other variations? Thanks

«Randy


#7

No, this is sticky and should not change between sessions. But sometimes it mysteriously resets itself, nobody knows why. It happens on the Windows side, has for a long time, but seems more frequent on the Mac side now.

so if you see funny stuff happening, you can check and then run it once; use DivideAlongCreases as above to fix any bad parts.

–Mitch


#8

Thanks a lot and I will do.
«Randy