HI all
This time i really need your help. I am traying change the color of an object. Let me explain please.
1. Select a button that has the next code Autodesk.Navisworks.Api.Application.ActiveDocument.Tool.Value = Autodesk.Navisworks.Api.Tool.Select;
2. I select a object (pipe) and then ...
3. Press the other button to change the color of that object.
I dont have much experience.... please help me. Attached a screenshot.
Regards
Sergio Franco.
Solved! Go to Solution.
Sergio,
See If This Works
//Begin Code using NavAPI = Autodesk.Navisworks.Api; // m_Color should be the Color Selected example: #FFFFFF System.Windows.Media.Color m_CompColor =(Color)System.Windows.Media.ColorConverter.ConvertFromString ( m_Color ); // NavAPI.Application.ActiveDocument.Models.OverridePermanentColor ( NavAPI.Application.ActiveDocument.CurrentSelection.SelectedItems, new NavAPI.Color ( Convert.ToDouble(m_CompColor.R) / 255, Convert.ToDouble(m_CompColor.G) / 255, Convert.ToDouble(m_CompColor.B) / 255 ) ); //End Code
Sergio,
I forgot to add this line of Code at the Very end
NavAPI.Application.ActiveDocument.CurrentSelection.Clear();
Colin
KempCE
Just one error appears, "m_color does not exist in the current context" for try if this works. Help me please...
Regards,
SF
Sergio,
In your picture you showed a Button with a Color that the User Selects to change the color. Change m_Color to that Color Selection
Regards,
Colin
KemCE
the code is..
string color = "RED";
// m_Color should be the Color Selected example: #FFFFFF
System.Windows.Media.Color m_CompColor = (System.Drawing.Color)System.Windows.Media.ColorConverter.ConvertFromString
(color
);
//
Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor
(
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems,
new Autodesk.Navisworks.Api.Color
(
Convert.ToDouble(m_CompColor.R) / 255,
Convert.ToDouble(m_CompColor.G) / 255,
Convert.ToDouble(m_CompColor.B) / 255
)
);
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Clear();
when i change m_color by color that is "string color ="RED;". Appears an error "Cannot implicity convert type"System.Drawing.Color" to "System.Windows.Media.Color" ". Please am i doing something wrong??
Regards,
SF
Colin
Thanks a lot, again...
here is the code
System.Drawing.Color c = System.Drawing.Color.Red;
string strcolor = System.Drawing.ColorTranslator.ToHtml(c);
//Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor(IEnumerable<ModelItem>, Autodesk.Navisworks.Api.Color.Red);
// m_Color should be the Color Selected example: #FFFFFF
System.Windows.Media.Color m_CompColor = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString
(strcolor
);
//
Autodesk.Navisworks.Api.Application.ActiveDocument.Models.OverridePermanentColor
(
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems,
new Autodesk.Navisworks.Api.Color
(
Convert.ToDouble(m_CompColor.R) / 255,
Convert.ToDouble(m_CompColor.G) / 255,
Convert.ToDouble(m_CompColor.B) / 255
)
);
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Clear();
Regards,
SF
Colin
I am very grateful for your help. Please could you help me with the next.
I am trying to use the function "HIDE UNSELECTED" from my app. I try with the next...
private void button14_Click(object sender, EventArgs e)
{
Autodesk.Navisworks.Api.Application.ActiveDocument.Models.SetHidden(Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.SelectedItems, true);
Autodesk.Navisworks.Api.Application.ActiveDocument.CurrentSelection.Clear();
}
but the result is other. How can i do it??
Please Help.
Best Regards,
SF
Can't find what you're looking for? Ask the community or share your knowledge.