RhinoCommon transformation failure


#1

Hi there,

The test script below is part of a bigger project. I am trying to rotate a group of objects relative to the world Top view, then shear them over -45° relative to the Right view - using Python/RhinoCommon (WIP).

If you run the script with the first file - “StraightPosts”, it works fine The file is exclusively boxes. If you run it on the second file “StraightPosts2” - which are the same boxes but have some round rods that run through them so they have holes, it fails - on the shear step.

Does anyone know why the shear transformation fails in this case?

Thanks,
–Mitch

RotateShearTest.py (1.9 KB)
StraightPosts.3dm (884.0 KB)
StraightPosts2.3dm (6.4 MB)


#2

I would narrow it down by testing where in the code the Breps looses their Guids. They’re all “0000-0000…0000” at line 51 when processing StraightPosts2, but not on StraightPosts :

50    for obj in objs:
51        objID=sc.doc.Objects.AddBrep(obj)         <-- "empty" guids.

Edit: The objects seems to lose their guids at row 62 (I’ve added some lines for testing) :

58    TestGuidsOK("#2", objs)
59    
60    #Do shear
61    rs.Prompt("Calculating projection...")
62    xform=Rhino.Geometry.Transform.Shear(xy_plane,x_scale,y_scale,z_scale)
63    [obj.Transform(xform) for obj in objs]

65    TestGuidsOK("#3", objs)

RotateShearTest_test.py (2.4 KB)

// Rolf


#3

Yes, that’s correct, the GUIDS end up as System.Guid.Empty - which usually means that the “virtual” geometrical objects in question were invalid and thus not added to the document.

My question is not where they are failing, but why… My feeling is that this particular transformation is valid for linear objects, but not for curved ones, but I want to understand why - and also how to fix it if possible…

–Mitch


#4

Yes of course. Can’t help you there though.

// Rolf


#5

Anyone with any clues…? Haven’t had time to get back to this lately, but still would like to know why this fails and how to fix…

Thx, --Mitch


#6

This is a brep version of this problem with curves:

except RhinoCommon doesn’t allow invalid breps to be added to the document.

Before each Transform, add:

    if xform.SimilarityType == Rhino.Geometry.TransformSimilarityType.NotSimilarity:
        [obj.MakeDeformable() for obj in objs]

#7

Ahh, very nice @spb , thank you! I wouldn’t have found that one…

Now I can continue with my project - once I get some more time here.

Cheers, --Mitch