Awhile back, you wrote an article on Ribbon manipulation for both AutoCAD and Revit modifications. I was wondering, can this be done using Dynamo / Python script instead of C# which seems more native for Addin Development?
I am curious if anyone else has tried to do this and have only currently been successful using the Rhythm Package for Color Manipulation (But not able to do gradient)
Man, I love thisâŚlooks like someone pulled the thumbtack from the right hand corner! You just need to animate it and play a creaking noise followed by the sound of something breaking (probably revit)!
@Kibar, what would the code be then for allowing for gradient color modifications? I have seen the tilt one but not for gradient colors as illustrated in the article?
Compare the python code to the c# code on jeremy´s page and apply it similarly to the function you´re looking for.
Create clr references to the right assemblies and import the needed modules. You can find in the .NET Frameworks docs the function you´re looking for and see in which .dll it is.
Still trying to get it right:
Version:0.9 StartHTML:00000097 EndHTML:00001822 StartFragment:00000199 EndFragment:00001784 import clr
clr.AddReferenceByPartialName(âSystem.Windows.Formsâ)
clr.AddReference(âPresentationCoreâ)
clr.AddReference(âAdWindowsâ)
import System.Windows.Forms as winform
import Autodesk.Windows as adWin
from System.Windows.Media import Colors
Kibarâs example specifically shows how to transform (or Rotate, in this case) the UIElement (Ribbon). I would try translating the code from Jeremyâs post into IronPython as best you can. For example, this (C#):
foreach( adWin.RibbonTab tab in ribbon.Tabs )
{
foreach( adWin.RibbonPanel panel in tab.Panels )
{
panel.CustomPanelTitleBarBackground
= gradientBrush;
panel.CustomPanelBackground
= picBrush; // use your picture
//panel.CustomPanelBackground
// = gradientBrush; // use your gradient fill
}
}
Would be this (IronPython):
for tab in ribbon.Tabs:
for panel in tab.Panels:
panel.CustomPanelTitleBarBackground = gradientBrush
panel.CustomPanelBackground = picBrush # use your picture
This is what you had originally written (I have included some comments as well):
clr.AddReferenceByPartialName('System.Windows.Forms')
clr.AddReference('PresentationCore')
clr.AddReference('AdWindows')
import System.Windows.Forms as winform
import Autodesk.Windows as adWin
from System.Windows.Media import Colors
def color_ribbon(color):
ribbon = adwin.ComponentManager.Ribbon
# Ribbon with a capital R is the class itself, not your ribbon object
# Colors does not have any public constructors
# This would have to instead be Colors.AliceBlue
Ribbon.RenderTransform = Colors(color)
return ribbon
# The data being passed to color_ribbon is not a string
# This would raise a NameError (name 'FFF0F8FF' is not defined)
OUT = color_ribbon(FFF0F8FF)
This is closer to what youâre looking for (although it isnât functional yetâsomeone else on the forum with more experience in UI design will probably be able to provide more direction):
clr.AddReferenceByPartialName('System.Windows.Forms')
clr.AddReference('PresentationCore')
clr.AddReference('AdWindows')
import System.Windows.Forms as winform
import Autodesk.Windows as adWin
from System.Windows.Media import ColorConverter
def color_ribbon(color):
ribbon = adWin.ComponentManager.Ribbon
color_converted = ColorConverter.ConvertFromString(color)
# Use color_converted to set the background color
# Etc etc. This code doesn't yet actually modify the Ribbon's color
return ribbon
# Make sure to provide a string and include the pound sign
OUT = color_ribbon('#FFF0F8FF')
I am curious though, could you use an image file as well? I have had success with color and rotate, but not the Gradient or Image use? Any suggestions?