Page 1 of 1
selecting material by object
Posted: Sat May 17, 2014 3:22 pm
by polynurb
is there a way, if i don not use auto-select material, to make the material of the currently selected object active in the editor by using a keyboard stroke, or alias?
auto-select has some performance impact on big scenes and i would like a way to quickly get the current object's material without r-clicking or going through the properties.
Re: selecting material by object
Posted: Sat May 17, 2014 5:27 pm
by JDHill
There's no command for it, but you can make one; open nodepad, paste in this script, and save it as "SelectMaxwellMaterialOfSelectedObject.rvb":
Code: Select allOption Explicit
Rhino.AddStartUpScript Rhino.LastLoadedScriptFile
Rhino.AddAlias "SelectMaxwellMaterialOfSelectedObject", "_NoEcho _-Runscript (SelectMaxwellMaterialOfSelectedObject)"
Sub SelectMaxwellMaterialOfSelectedObject()
Dim objects: objects = Rhino.SelectedObjects
If IsArray(objects) Then
Dim obj: obj = objects(0)
Dim idx: idx = Rhino.ObjectMaterialIndex(obj)
If idx > -1 Then
Dim name: name = Rhino.MaterialName(idx)
Rhino.Command "Maxwell_SetCurrentMaterial " & name & " _Enter"
End If
End If
End Sub
Dropping the .rvb on your viewport will add a new "SelectMaxwellMaterialOfSelectedObject" alias, which you can use in a toolbar button, or assign to a keyboard shortcut.
Re: selecting material by object
Posted: Sat May 17, 2014 6:19 pm
by polynurb
special weekend delivery.
very cool, thank you Jeremy. works perfectly
Re: selecting material by object
Posted: Sat May 17, 2014 6:49 pm
by polynurb
Hi,
one little thing
Command: SelectMaxwellMaterialOfSelectedObject
Command: Maxwell_SetCurrentMaterial
Enter Material Name <X_SuCi_StreetFin_P1>: X_SuCi_StreetFin_P1
Maxwell: Current Material set to: X_SuCi_StreetFin_P1.
Command: (2)
Unknown command: (2)
..because the material was cloned "(2)" with space in between.
i guess this needs extra "" somewhere?
but i can't quite figure out where/how
Re: selecting material by object
Posted: Sat May 17, 2014 7:05 pm
by JDHill
This should be what you're looking for:
Code: Select allRhino.Command "Maxwell_SetCurrentMaterial """ & name & """ _Enter"
So, you are adding string + name + string, where the two strings are enclosed in quotation marks; inside the strings, you write a single quotation mark by using two of them (if you used one, that would end the string, and you'd have a loose quotation mark sitting outside it).
Re: selecting material by object
Posted: Sat May 17, 2014 7:14 pm
by polynurb
great!
thanks for the insight.good to know