Thanks TIG! I thought clone might have to be the approach, glad I got confirmation before heading down that path. I got it working in my code. However, did get one annoying side effect. My code creates several nested components, and for just one of the nested components all the faces end up inside out after cloning. I fixed it for now by using face.reverse!, but wanted to check if anybody knew why SketchUp was reversing the face normals for just one nested subcomponents created by cloning. I'm guessing the reversal could be avoided if I'm cloning entities in a specific order.
Latest posts made by Shoff
-
RE: Creating a nested component
-
Creating a nested component
Hi Everybody,
So, I'm trying to create a sub component and add entities from the parent component that satisfy a set of conditions. Been banging my head on the problem for a while and could use some explanation of how to make this work. Hoping that somebody that understands the nuances of add_group can break it down for me.
Overview:
Here's a sample model: https://dl.dropbox.com/u/4116128/example.skp
Here's what i want the output to look like: https://dl.dropbox.com/u/4116128/example-after.skp
When you look at each example model, make sure to turn on hidden geometry. If you look in outliner, you'll see that I selected the top left geometry of the component (manually), selected "make component", and chose to "Replace selection with component".
Below is part of the code I wrote to try to achieve the same outcome, it assumes you have selected the component in the model. Warning, this code causes a BUG SPLAT when you quit SketchUp.
am = Sketchup.active_model ci = am.selection[0] cd = ci.definition ents = cd.entities off = 8 max = [8.0, 82.25] tl_a = [] cd.entities.each do |ent| b_max = ent.bounds.max b_min = ent.bounds.max if b_max.x <= off && b_min.z.to_i >= (max[1] - off) tl_a<<ent end end tl_grp = ents.add_group tl_a
-
SketchUp API Documentation for redraw and redraw_with_undo
Hi All,
Figured out how to do redraw based on a discussion on the Sketchucation forums, but wondering why I can't seem to find any mention of redraw and redraw_with_undo methods in the SketchUp API documentation. Are they there and I'm just not looking hard enough? -
RE: Question about load_handler parameter from load_from_url
Yeah, I posted a bug report. One more thing worth mentioning for anybody that finds this thread later. When I said that it worked on a PC, I got it to work using Sketchup.status_text=, but it wouldn't work using WebDialog.execute_script. I wrote a little script to slowly count from 1 to 100 and call my javascript each time, so that I could make sure that it wasn't some silly mistake on my end, and that worked fine. So, my assumption is that execute_script is taking forever to get called inside of onPercentChange even for the PC.
-
RE: Question about load_handler parameter from load_from_url
I think I figured out the problem. onPercentChange doesn't work on a mac. Just tried my code on a PC, and it worked. Guess that means bug report...kind of wish I tested that sooner, would have saved me a lot of time.
-
RE: Question about load_handler parameter from load_from_url
hmmm. Yeah, i did something very similar to your onPercentChange definition, and it doesn't look like SketchUp is calling it. I know my javascript works because if I call load_handler.onPercentChange(foo) where foo is a number, then my progress bar updates. When you run load_from_url with the optional load_handler parameter, is SketchUp calling onPercentChange for you?
-
RE: Question about load_handler parameter from load_from_url
How frequently does SketchUp call it? Can I control the interval? Or is it just that I specify the interval at which it does something inside of the onPercentchange method?
-
RE: Question about load_handler parameter from load_from_url
That's what I was hoping, but what is the argument that you are passing doing? In the prototype on the api page, it shows that you have to pass an argument, and then it's basically just printing that p argument. What is p supposed to be conceptually?
class LoadHandler def onPercentChange(p) Sketchup;;set_status_text("LOADING; " + p.to_i.to_s + "%") end def cancelled? # You could, for example, show a messagebox after X seconds asking if the # user wants to cancel the download. If this method returns true, then # the download cancels. return false end def onSuccess Sketchup;;set_status_text('') end def onFailure(error_message) # A real implementation would probably not use a global variable, # but this demonstrates storing any error we receive. $last_error = error_message Sketchup;;set_status_text('') end end
-
Question about load_handler parameter from load_from_url
I'm using the load_handler option parameter for load_from_url, and I'm a little confused about how the onPercentchange method is supposed to work which is a piece of the bigger problem with load handling that I'm trying to resolve.
Progress Bar:
A little background, I'm trying to use a jquery ui progress bar to show the progress of the sketchup file being downloaded, and, my plan is to, at regular interval, fire off a request that takes the pulse of the download and returns the completion status. I need some way of taking the pulse of the download process. Anybody got an idea how to do that? -
RE: [Code] Sketchup.send_action() : Arguments to
Realized I need to clarify. Those arguments return true, but nothing happens. Dialogs don't show up, etc. Do they work on a PC?