Addpictureframe problem

Hey everyone,
I’m facing this problem when I’m using Rhinocommon. But when I use rhinoscriptsyntax everything is OK.
The problem is when radius of circle is 1 in both way everything is ok,
[Python = left, Rhinocommon = right]

but when I increase radius to 2, Rhinocommon won’t draw it correctly.

another problem is background transparency which is ok in python but I can find any workaround for C#.
Can anyone tell me its a bug or Im doing smth wrong?
Python:

ids = rs.GetObjects("Select points", 1)
frames = ['frame1', 'frame2', 'frame3', 'frame4', 'frame5']
for id in ids:
    point = rs.PointCoordinates(id)
    circle = rs.AddCircle(point,2)
    circumference = rs.CircleCircumference(circle)
    picpos = circumference / len(frames)
    param = 0
    for frame in frames:
        frame = rs.CurveFrame(circle, param, -1)
        origin = rs.EvaluatePlane(frame, [0, 0])
        circ = rs.AddCircle(origin, 0.2)
        frm = rs.CurveFrame(circ, 0, -1)
        b = rs.AddPictureFrame(frm, "smth.png", 0.4, 0.4, False, True, True, False)
        indexb = rs.ObjectMaterialIndex(b)
        rs.MaterialTransparencyMap( indexb, "smth.png" )
        param += picpos
 scriptcontext.doc.Views.Redraw()

C#:

   const ObjectType filter = ObjectType.Point;
   var rc = RhinoGet.GetMultipleObjects("Sample points", false, filter, out ObjRef[] points);
           foreach (var basepoint in points)
            {
                var point = basepoint.Point();
                var cord = point.Location;
                Circle circle = new Circle(cord, 1);
                doc.Objects.AddCircle(circle);
                Curve crva = circle.ToNurbsCurve();
                double circumference = circle.Circumference;
                double picpos = circumference / frames.Count;
                double param = 0;
                foreach (Plane item in frames)
                {
                    Plane frame = item;
                    crva.FrameAt(param, out frame);
                    Point3d origin = frame.Origin;
                    Circle circ = new Circle(origin, 0.2);
                    Curve crv = circ.ToNurbsCurve();
                    crv.FrameAt(0, out Plane frm);
                    Guid picid = doc.Objects.AddPictureFrame(frm, "smth.png", false, 0.4, 0.4, false, false);
                    RhinoObject picobj = doc.Objects.FindId(picid);
                    int picMtrl = picobj.Attributes.MaterialIndex;
                    var mat = doc.Materials[picMtrl];
                    mat.AlphaTransparency = true;
                    param += picpos;
                }
            }
     doc.Views.Redraw();

I’m using Rhino 7.6.21127.19001

Thank you in advance.

any idea? nobody?

rhinoscriptsyntax always eventually ends up calling RhinoCommon

If you place a breakpoint your python script, you should be able to step into all of the rhinoscriptsyntax functions and see exactly which RhinoCommon functions they are eventually calling.

Alternatively, you could look at the rhinoscriptsyntax source. Here is the MaterialTransparencyMap function implementation

1 Like

@stevebaer Thank you for reply. So if I understand correctly there is no direct method in rhinocommon like python. I wrote the definition in c# and yes it works correctly.
And do u have any idea why addpictureframe behave like this in rhinocommon?

The rhinoscriptsyntax python functions are high level wrappers around a set of RhinoCommon functions. I don’t currently have the time to test your script, but by the looks of it you are not setting a material transparency map in C# like you are in python.

1 Like

Thank you anyway.

Can somebody checks if it is a bug or not? Addpictureframe behave differently in c# and python.

The problem is when radius of circle is 1 in both way everything is ok,
[Python = left, Rhinocommon = right]
but when I increase radius to 2, Rhinocommon won’t draw it correctly.

Hi @bahman.farshbaf,

Your C# code is directly portable to Python without the use of rhinoscriptsyntax. You should do that.

– Dale

Thanks @dale for the reply. anyway I don’t need more than “1” as radian for my project…but it sounds weird to me…both codes are same and are using same syntax…but c# wont draw correctly in higher radians…