Windows Forms PictureBox y Group

Hi,
you need to use this method
you can also store your image as base64 directly in your script

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('System.Drawing')
clr.AddReference('System.Windows.Forms')
import System.Drawing
import System.Windows.Forms

from System.Drawing import *
from System.Windows.Forms import *

class Form9(Form):
	def __init__(self, base64Str):
		self._base64Str = base64Str
		self.InitializeComponent()
	
	def InitializeComponent(self):
		self._pictureBox1 = System.Windows.Forms.PictureBox()
		self._pictureBox1.BeginInit()
		self.SuspendLayout()
		# 
		# pictureBox1
		# 
		picTop = System.Convert.FromBase64String(self._base64Str)
		self._imageTop = System.Drawing.Image.FromStream(System.IO.MemoryStream(picTop))
		self._imageTopResize = Bitmap(self._imageTop, Size(100, 100))
		self._pictureBox1.Location = System.Drawing.Point(45, 67)
		self._pictureBox1.Name = "pictureBox1"
		self._pictureBox1.Size = System.Drawing.Size(100, 100)
		self._pictureBox1.TabIndex = 0
		self._pictureBox1.TabStop = False
		self._pictureBox1.Image = self._imageTopResize
		# 
		# Form9
		# 
		self.ClientSize = System.Drawing.Size(284, 261)
		self.Controls.Add(self._pictureBox1)
		self.Name = "Form9"
		self.Text = "Form9"
		self._pictureBox1.EndInit()
		self.ResumeLayout(False)
		
objForm = Form9(IN[0])
objForm.ShowDialog()

demoBase64_Winform.dyn (16.3 KB)

4 Likes