Materials from face to components
-
I am looking for a plugin with which I can transfer the material from the face to the first component. Does anyone have an idea or something for this?
-
Please expand on this.
There's probably insufficient detail to give a useful reply.
However, here's my attempt at recasting what I think you mean...-
You want a Plugin which will find a particular face's material and apply that material onto a particular component-instance.
-
How is the chosen face to be determined ?
-
How is the affected component-instance to be determined ?
-
Is there more than one instance of this component ?
-
Is the face actually nested inside the component that is to receive the material ?
-
Is that nested face to have its material removed after it's applied to the 'container' ?
-
Is this to only affect component-instances, or are groups also to be considered ?
But... why can't you use the eyedropper-tool from the 'Materials Browser' dialog, and pick to select the desired face's material, then use the paint-bucket to paint the 'container', just as if you had selected the material off the browser itself ? Editing the container, and then exiting the edit, as necessary to access the face and container as needed.
Note: to wipe a face's material, just select it with a single-click and use 'Entity Info' to reassign its front-material from the top icon-click and the 'default material which is always first in the swatches in the 'Choose Paint' dialog... -
-
@tig said:
Please expand on this.
There's probably insufficient detail to give a useful reply.
However, here's my attempt at recasting what I think you mean...-
You want a Plugin which will find a particular face's material and apply that material onto a particular component-instance.
-
How is the chosen face to be determined ?
-
How is the affected component-instance to be determined ?
-
Is there more than one instance of this component ?
-
Is the face actually nested inside the component that is to receive the material ?
-
Is that nested face to have its material removed after it's applied to the 'container' ?
-
Is this to only affect component-instances, or are groups also to be considered ?
But... why can't you use the eyedropper-tool from the 'Materials Browser' dialog, and pick to select the desired face's material, then use the paint-bucket to paint the 'container', just as if you had selected the material off the browser itself ? Editing the container, and then exiting the edit, as necessary to access the face and container as needed.
Note: to wipe a face's material, just select it with a single-click and use 'Entity Info' to reassign its front-material from the top icon-click and the 'default material which is always first in the swatches in the 'Choose Paint' dialog...I will explain why I could use this well. I now use an xref plugin to load an autocad drawing into sketchup. Then I place this loaded 98x component on a site plan of a building. then I export an .ifc of this.
the problem is that now the colors are not exported because the colors of the composet are being exported but these are with a loaded .dwg the layer of colors from autocad.
I could adjust this manually, but the autocad model is still often adjusted.
-
-
Unfortunately that explanation makes it even less clear.
Where is the 'face' ?
Where is the component-instance ?
Where does the layer's color come into this ?Please explain how you do it manually, step-by-step - in very simple terms...
I appreciate that it's likely that English is not your first language, so keep it very simple, to avoid things getting lost in translation... -
@tig said:
Unfortunately that explanation makes it even less clear.
Where is the 'face' ?
Where is the component-instance ?
Where does the layer's color come into this ?Please explain how you do it manually, step-by-step - in very simple terms...
I appreciate that it's likely that English is not your first language, so keep it very simple, to avoid things getting lost in translation...step 1 dwg import via xref
step 2 copy xref component on a map
step 3 open the xref component, the components contained therein provided with the same material as there is on the surface of the component
stap 4 when I export the drawing to .ifc all components have the material / color of the component (green). this should be the material / color of face.So it would be handy if there were a plugin that would copy the material / color of the face to the component that contains the face.
-
How do we determine the color you want for the component-instance ?
There seem to be several different materials on various faces [or even sub-components] inside it ?If you select the component-instance and give it the default material in Entity Info then how does it export ?
IFC always applies the 'container's' material to nested faces - the faces' materials are ignored.
Try this one-liner, copy and paste it into the Ruby Console + enter.
It examines the model's definitions and finds the first face inside each component-definition that has a material, it then applies that material [if any] onto every placed instance of that component.Sketchup.active_model.definitions.each{|d|next if d.group?||d.image?;ms=[];d.entities.grep(Sketchup;;Face).each{|f|ms<<f.material};m=ms.compact[0];d.instances.each{|i|i.material=m}}
-
@tig said:
How do we determine the color you want for the component-instance ?
There seem to be several different materials on various faces [or even sub-components] inside it ?If you select the component-instance and give it the default material in Entity Info then how does it export ?
IFC always applies the 'container's' material to nested faces - the faces' materials are ignored.
Try this one-liner, copy and paste it into the Ruby Console + enter.
It examines the model's definitions and finds the first face inside each component-definition that has a material, it then applies that material [if any] onto every placed instance of that component.Sketchup.active_model.definitions.each{|d|next if d.group?||d.image?;ms=[];d.entities.grep(Sketchup;;Face).each{|f|ms<<f.material};m=ms.compact[0];d.instances.each{|i|i.material=m}}
All sub-components only have 1 surface material.
If I give the component standard material then it is all exported as light gray.
This is exactly what I was looking for and works great. This saves me so much time thanks a lot !!
Is it also possible to process this in a plugin?
And can it then be that it only processes selected components when something is selected? -
This alternative one-liner will process all selected component-instances, making those instances take the material of the first face found within the component's definition.
ms=[];mod=Sketchup.active_model;mod.selection.grep(Sketchup;;ComponentInstance).each{|i|d=i.definition;d.entities.grep(Sketchup;;Face).each{|f|ms<<f.material};m=ms.compact[0];i.material=m};
To make a menu item of such simple commands you can try the following.
It's not difficult - just take care...Use a plain-text editor, like Notepad++ [or TextWrangler on a MAC], and add a new file into your Plugins folder*** named say 'MyOneLiners.rb' - ensure that its encoding is set to UTF-8.
Add this line to the very start of the file to be on the safe side:
# encoding: UTF-8
Then add the following line for each 'one-liner'...
UI.menu("Plugins").add_item("TITLE"){CODE}
Substituting your desired 'name' for your command in place of TITLE [keeping the paired ""], and also copy and paste the full code into where it says CODE [leaving the pair of enclosing {} ]
Do a new line for each command you want.
Save the RB file, and restart SketchUp to see your new command[s] listed under the SketchUp Extensions menu [previously called Plugins]...
***To open your Plugins folder [which is hidden by default] just copy+paste+enter this one-liner into the Ruby Console:
UI.openURL("file;///#{Sketchup.find_support_file('Plugins')}")
You could even add that command to your menu items, as say "OpenMyPluginsFolder" !
-
@tig said:
This alternative one-liner will process all selected component-instances, making those instances take the material of the first face found within the component's definition.
ms=[];mod=Sketchup.active_model;mod.selection.grep(Sketchup;;ComponentInstance).each{|i|d=i.definition;d.entities.grep(Sketchup;;Face).each{|f|ms<<f.material};m=ms.compact[0];i.material=m};
To make a menu item of such simple commands you can try the following.
It's not difficult - just take care...Use a plain-text editor, like Notepad++ [or TextWrangler on a MAC], and add a new file into your Plugins folder*** named say 'MyOneLiners.rb' - ensure that its encoding is set to UTF-8.
Add this line to the very start of the file to be on the safe side:
# encoding: UTF-8
Then add the following line for each 'one-liner'...
UI.menu("Plugins").add_item("TITLE"){CODE}
Substituting your desired 'name' for your command in place of TITLE [keeping the paired ""], and also copy and paste the full code into where it says CODE [leaving the pair of enclosing {} ]
Do a new line for each command you want.
Save the RB file, and restart SketchUp to see your new command[s] listed under the SketchUp Extensions menu [previously called Plugins]...
***To open your Plugins folder [which is hidden by default] just copy+paste+enter this one-liner into the Ruby Console:
UI.openURL("file;///#{Sketchup.find_support_file('Plugins')}")
You could even add that command to your menu items, as say "OpenMyPluginsFolder" !
Work fine thanks for the help !!
Advertisement