Why not enable us pro users to drag and drop the files SU can import? OR Make Sketchup import the things it's able to import when we choose open with sketchup? Then the users like me who always start with an existing file (me: dxf) don't have to launch SU and import 50 times a day. We could set SU as the default for those files and double click.
Posts made by Eric_Erb
-
RE: Product Ideas for SketchUp
-
RE: Automaticaly try to import files that aren't .sku
@chris fullmer said:
Use the model.import method
I know this command but what I'm looking to do is write something that will automatically try to import a file if you get the "This Does Not Appear To Be A Sketchup Model!" dialog. Or, really anything that will result in SU opening the dxf when it's double clicked. Should I maybe compile an executable ruby script that says open SU and run the model.import command with the "file name" portion of the script derived from the source file (original NAME.dxf file)? Then I could set that as the default program for dxf files. And by the way, I have no idea how to do what I just suggested.
-
Automaticaly try to import files that aren't .sku
I've been writing a ruby script that automates a bunch of steps I usually have to do by hand. So I've written with a lot of help from you guys 9 little ruby scripts so far that take care of most of the steps. As I get closer to being complete with all of them, I get more worried about finding a solution to the very first step. STEP1... Opening the file. It's easy enough to set the default program for a file type the problem is I'm opening .dxf not sku. I am of course using Sketchup Pro. My question is this... Is there a way with ruby to tell sketchup to try to import the file when it can't directly open it? Or, just add the ability for sketchup to open .dxf?
-
RE: Combining a plgn that uses a class for the def w/other plgns
Thank you. You know in hind sight that makes perfect sense. I guess the whole class in the def thing just though me. I am definitely not a programmer so when I see something I'm not used to seeing it throws me off. Thanks again
-
Combining a plgn that uses a class for the def w/other plgns
I was queuing up a list of scripts to run sequentially as a ruby plug in. Easy enough...
require "plugin_name.rb"
and then thedef
from that plugin I want to run.I added three plugins and the script runs great. The problem came when I started to add the fourth. There are two problems with it...
- the plugin runs on a button click in the Sketchup UI and the plugin is actually in another folder within the plugin folder
- instead of a regular
def
it introduces a class... "SwivelButton" and from then on calls on that class + what I guess is a variable or extension as thedef
. i.e.def SwivelButton::init()
;def SwivelButton::getIndexFilePath()
; etc.
So, I don't know what do exactly. I thought calling on the first one
SwivelButton::init()
would be the way to go but as it doesn't start with a lowercase letter it didn't work at all. I tried doing a find and replace to exchange the "S" with an "s" but that ended horribly. Any suggestions? This is google's web exporter plugin by the way. -
RE: Use Ruby To Apply Materials to Spacific Layers
@runnerpack said:
this script could be handy for others who may not want to make sure every layer has a material, and vice versa, just to keep it from wiping out their already-assigned materials.
Sorry, I didn't think about people not wanting to replace all the materials on every layer. Thank you so much RunnerPack. You have been a life saver... Now I just gotta read the little book of ruby a few more times (I just finished the second read) last night), and maybe this will finally click. You know I didn't have near the same difficulty learning AS3 or HTML.
-
RE: Use Ruby To Apply Materials to Spacific Layers
On Sketchup Load it's returning... undefined method `file_loaded' for main:Object. is there something here I'm supposed to change before I save it to plugins? By the way unless it will crash the script otherwise, there's no need for the script to make sure there's a material that matches the layer name before it runs. Like I said... The Layers are always named the same so when I create materials named after the layer names there will always be a material for each of the layers.
-
RE: Use Ruby To Apply Materials to Spacific Layers
Thank you RunnerPack, I'll try that approach right now. Yes, I did mean setting them to the default materials
-
RE: Use Ruby To Apply Materials to Spacific Layers
Alright, I've been messing around with the code... This is it as it is now...
` module Eric_Erb
def self.color_by_layer
su_materials = Sketchup.active_model.materials
my_materials = Hash.new
my_materials["Wall_Surfaces"] = su_materials["Roofing_Metal_Standing_Seam_Red"]
my_materials["Roof_Surface"] = su_materials["Roofing_Slate_Tan"]
# .. and so on.begin Sketchup.active_model.start_operation("Color By Layer", true) rescue ArgumentError Sketchup.active_model.start_operation("Color By Layer") end # Loop through entities & apply material based on layer name Sketchup.active_model.entities.each do |entity| if entity.is_a? Sketchup::Drawingelement entity.material = my_materials[entity.layer.name] end end Sketchup.active_model.commit_operation end
end
UI.menu('Plugins').add_item("Color by Layer") { Eric_Erb.color_by_layer }`
I didn't add anymore Layers to apply materials to just to see if I could get it running as is. It doesn't apply materials though. The line: su_materials = Sketchup.active_model.materials, I thought that might mean "referance the materials already active in the model", so I created a couple shapes on different layers and applied the materials I wanted to use to those and when I ran the plug-in it actually removed the materials from my new layers, so I guess I interpreted that line wrong. I'm sure my error is completely obvious to people like you that can rap their heads around coding like this (which is absolutely amazing by the way), but can you tell me where I'm messing this up?
-
RE: Use Ruby To Apply Materials to Spacific Layers
Thank you Jim! I'm trying to make that bit of code work now. To answer your questions...I could easily rename the materials if it meant simpler code. My layer names are formatted "Wall_Surfaces", "Roof_Surface", etc. so I could rename the material on the walls "Wall_Surface" if that would help. I'm not sure what the difference is in applying a material to a group or the entities within a group. If you're asking if groups will need to include different materials for it's entities, no. All the entities within a group are the same material. Also, there is only one instance of each component.
-
RE: Use Ruby To Apply Materials to Spacific Layers
I need to apply the materials to objects in the Model based on their Layer... Hopefully automatically
-
RE: Use Ruby To Apply Materials to Spacific Layers
I have to do like 50 of these things a day so I'd like to automate it basically. I really don't care what method or medium I need to use as long as it will for instance apply the brick material to any layer named Wall_Surfaces whenever I open a file. It just seemed like from my research Ruby would be my best bet, but I am wide open to other options.
-
Use Ruby To Apply Materials to Spacific Layers
Hello, and Thank you all in advance for your advice. I'd like to start my saying I've been modeling in sketchup, rhino, and solidworks for years but I am very new to programing. The program we use automatically exports our designs as .dxf files with layers. Part of my job requires me to import these files to sketchup and apply a material to each layer of the dxf. These layers are always named the same and the materials are always the same so there must me a way to write a little ruby script that will automatically apply those materials to their respective layers. Can anyone help me out?