本帖最后由 筑梦NARUTO 于 2019-9-9 17:05 编辑
今天有群友问“如何用Ghpython导出gh电池Help的描述”。简单分享一下代码。希望对大家有帮助。
[AppleScript] 纯文本查看 复制代码 #coding=utf-8
import rhinoscriptsyntax as rs
docObjs = ghenv.Component.OnPingDocument().SelectedObjects()
for obj in docObjs:
objHelp = []
objHelp.append(obj.Name)
objHelp.append('\n')
objHelp.append(obj.Description)
objHelp.append("\n")
parInput = obj.Params.Input
parOutput = obj.Params.Output
objHelp.append("Input parameters: ")
for inp in parInput:
index1 = str(inp).find('_')
index2 = str(inp).find(' ')
objHelp.append(inp.NickName + "(" + str(inp)[index1+1:index2] + ")")
objHelp.append(inp.Description)
objHelp.append("\n")
objHelp.append("Output parameters:")
for oup in parOutput:
index1 = str(oup).find('_')
index2 = str(oup).find(' ')
objHelp.append(oup.NickName + "(" + str(oup)[index1+1:index2] + ")")
objHelp.append(oup.Description)
objHelp.append("\n")
objHelp.append("====================================================================================================================")
objHelp.append("\n")
for p in objHelp:
print (p)
选中要导出help的电池,运行代码。代码运行之后,直接把panel导出txt。效果如下。
|