利用程式取得圓柱體的顏色碼將其轉換成RGB之後設定到方塊物件上。
|
(圖一) 欲取得圓柱的顏色並設定到方塊上 |
import ScriptEnv
ScriptEnv.Initialize("Ansoft.ElectronicsDesktop")
oDesktop.RestoreWindow()
oProject = oDesktop.GetActiveProject()
oDesign = oProject.GetActiveDesign()
oEditor = oDesign.SetActiveEditor("3D Modeler")
code = oEditor.GetPropertyValue('Geometry3DAttributeTab', "Cylinder1", 'Color')
AddWarningMessage(str(code))
code = int(code)
R= code % 256
G = ((code - R) % (256**2)) / 256
B = (code - R - 256*G) / 256**2
oEditor.ChangeProperty(
[
"NAME:AllTabs",
[
"NAME:Geometry3DAttributeTab",
[
"NAME:PropServers",
'Box1'
],
[
"NAME:ChangedProps",
[
"NAME:Color",
"R:=" , R,
"G:=" , G,
"B:=" , B
]
]
]
])
|
(圖二)執行腳本之後 |
沒有留言:
張貼留言