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

Addpictureframe problem

$
0
0

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.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 5852

Latest Images

Trending Articles



Latest Images