I want to write an interface in Dynamo in PythonScript, the language of the interface is Wxpython. The interface includes menu items. There is an item of cube in the menu. After clicking on the cube, an interface that can control the size of the cube comes out. Then enter the parameters in the dialog box that controls the size of the cube, and click OK. It can be modeled directly and quickly in Dynamo
Unless you’ve even attempted to begin writing such a routine in Python for Dynamo I doubt you will get any help/feedback.
Personally I don’t know how to do that, but figured best to advise you of this.
Thank you for your reply. I use Revit2022. I have written the interface in Wxpython and can display the interface in Dynamo, but after I bind the TextCtrl to the radius and height of the created ellipse, the input parameters cannot Successfully modeled in Dynamo, but never knew where the problem was
If you share your script including the interface that will help people assist you with the needed context.
We (the community) cannot hell you without some better insight into your code base. Post the full DYN including all relevant data sources, and refrain from duplicating posts going forward.
thanks for your suggestions
Post the DYN itself as well as any other necessary files to run the graph. We (the community) can’t troubleshoot your work from an image as you are well outside the normal scope of Dynamo work.
thank you for your reply, this is the code written in PythonScript in Dynamo. I am using Revit2022 version and Wxpython. The interface is achievable, but it cannot be modeled and there are no obvious errors. Is it true that the model implemented in Dynamo cannot be realized by simply using the interface to input data? Because the threads will conflict?
Hi @Dongzi …why dont you do as Jacob told you…share your files
Home.dyn (5.6 KB)
@jacob.small @sovitek This is what I achieved. I am a Chinese graduate student, so some of them are marked in Chinese. please have a look
your mainloop displays a window in a modal state and stop the execution of the Dynamo context, it’s necessary to exit the loop to continue
import clr
import sys
import re
import System
reDir = System.IO.DirectoryInfo(re.__file__)
path_py3_lib = reDir.Parent.Parent.FullName
sys.path.append(path_py3_lib + r'\Lib\site-packages')
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# 该节点的输入内容将存储为 IN 变量中的一个列表。
dataEnteringNode = IN
# 将代码放在该行下面
import wx
class MainFrame(wx.Frame):
def __init__(self, *args, **kw):
super(MainFrame, self).__init__(*args, **kw)
self.cylinder1 = None
self.InitUI()
def InitUI(self):
# 创建菜单导航栏
menuBar = wx.MenuBar()
# 子菜单栏
model_menu = wx.Menu()
# 添加菜单栏项
cylinder_item = model_menu.Append(-1, "Cylinder modeling", "Cylinder modeling")
# 添加菜单导航栏项
menuBar.Append(model_menu, "&Model")
# 将菜单导航栏至于页面上
self.SetMenuBar(menuBar)
# 绑定菜单栏项事件
self.Bind(wx.EVT_MENU, self.skip_to_cylinder, cylinder_item)
# 创建圆柱体建模面板
self.cylinder_panel = wx.Panel(self, -1, pos=(0, 0), size=(600, 400))
# 半径标签和输入框
self.text1 = wx.StaticText(self.cylinder_panel, -1, u'radius:', (160, 53), (50, -1), wx.ALIGN_CENTER)
font1 = wx.Font(15, wx.MODERN, wx.NORMAL, wx.NORMAL, False, 'Consolas')
self.text1.SetFont(font1)
self.textc1 = wx.TextCtrl(self.cylinder_panel, pos=(230, 50), size=(200, 30))
self.textc1.SetFont(font1)
# 高度标签和输入框
self.text2 = wx.StaticText(self.cylinder_panel, -1, u'high:', (160, 153), (50, -1), wx.ALIGN_CENTER)
self.text2.SetFont(font1)
self.textc2 = wx.TextCtrl(self.cylinder_panel, pos=(230, 150), size=(200, 30))
self.textc2.SetFont(font1)
# 确认和退出按钮
self.confirm_button = wx.Button(self.cylinder_panel, label="Ok", pos=(150, 250), size=(100, 40))
self.exit_button = wx.Button(self.cylinder_panel, label="quit", pos=(350, 250), size=(100, 40))
# 绑定按钮事件
self.confirm_button.Bind(wx.EVT_BUTTON, self.confirm_click)
self.exit_button.Bind(wx.EVT_BUTTON, self.exit_click)
# 首次打开页面不显示建模面板
self.cylinder_panel.Hide()
self.SetSize((600, 400))
self.SetTitle("Test Modeling")
self.Center()
self.Show()
# 跳转到圆柱体建模界面
def skip_to_cylinder(self, e):
self.cylinder_panel.Show()
self.textc1.SetValue("")
self.textc2.SetValue("")
# 确认按钮点击事件
def confirm_click(self, e):
radius = float(self.textc1.GetValue())
height = float(self.textc2.GetValue())
# 调用建模函数
point1 = Point.ByCoordinates(0, 0, 0)
point2 = Point.ByCoordinates(0, 0, height)
self.cylinder1 = Cylinder.ByPointsRadius(point1, point2, radius)
self.Close()
# 返回主页
def exit_click(self, e):
self.cylinder_panel.Hide()
ex = wx.App()
uiform = MainFrame(None)
ex.MainLoop()
OUT = uiform.cylinder1
@c.poupin Thank you very much for your reply, you are really amazing, thank you very much