Adding Option for _PictureFrame in GHpython


#1

Hi everyone,

I was trying to create a this component using GHpython for creating a Picture Frame and I have met with a dead wall with some issues:

  1. If there is way to achieve the same result without the action of baking the image directly in Rhino?

  2. The AddPictureFrame requires a Plane where the image will be inserted, how to tell it that I need the XY Rhino World plane ?
    PS: I have already tried giving it a point and the WorldXYPlane.

Geometry Rhino - Python - Unfinished.gh (11.2 KB)

Thank you in advance


#2

@Nader_Belal, have you tried the ImageSamplercomponent ?

you can set the rectangle in the image sampler. In python maybe this helps:

AddPictureFrameTest.gh (8.2 KB)

_
c.


#3

@clement

Thank you for your quick responce

Image Sampler component is a good option, but it doesn’t serve the purpose I need.

Why I´m getting this error message ?

Runtime error (MissingMemberException): 'ObjectTable' object has no attribute 'FindId'
Traceback:
  line 19, in DoSomething, "<string>"
  line 26, in script

#4

Probably because you’re not running it in Rhino 6. Rhino 5 does not know FindId method, you might exchange the following line:

rh_obj = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(frame_id)

with this for Rhino 5:

rh_obj = Rhino.RhinoDoc.ActiveDoc.Objects.Find(frame_id, True)

_
c.


#5

@clement

I have learnt a lot with the example you have sent me, and I would like to know:

  1. Why did you use Bitmap & not Image Class ? (I´m asking cause I’ve checked them and couldn’t understand)

  2. What is the function of Rhino.RhinoDoc.ActiveDoc class?


#6

I was just remembering that i could then get the width and height quickly. You can do the same using the image class of course:

image = System.Drawing.Image.FromFile(file_path)
w, h = image.Width, image.Height

If you’ve scripted using the python built in editor (_EditPythonScript) in the past, the method is used instead of scriptcontext.doc.
_
c.