@Arc_Plus wrote:
I am trying to create in the outliner, the slice group , I don’t find the API command to do it.
Can somebody help me?
Posts: 2
Participants: 2
@Arc_Plus wrote:
I am trying to create in the outliner, the slice group , I don’t find the API command to do it.
Can somebody help me?
Posts: 2
Participants: 2
@medeek wrote:
I’ve been looking at my “Draw Wall Tool” and I really like how the tool is now able to lock onto the X and Y axis. It would be convenient if I could also somehow have it lock to the 45 deg. line or the 135 deg. line.
I’m going to play around with it tonight but I thought I might put the question out there in case someone has done this before and prevent me from wasting a lot of time on reinventing the wheel.
Posts: 9
Participants: 3
@barry_milliken_droid wrote:
Sketchup.open_file filepath
will gracefully give an error message if the file was created in a newer version of SketchUpBut
Sketchup.active_model.definitions.load filepath
will result in a bugsplat in the same situation.Is there any way to test for the version of an skp file before load?
Posts: 2
Participants: 2
@Haraldos wrote:
Hi,
I have a question about a Ruby command. In one of my SketchUp models I have a dynamic roller conveyor. If I change the length, the number of rolls is recalculated. Now there are hundreds of rolls with instance names. If I export them to DWG there is the instance name over each roll.
Now I´m searching for a ruby command to delete all instance names from every component in the model.
I found this:
“Sketchup.active_model.definitions[“Name of component”].instances.name.each{|e|e.erase!}”
But it doesn’t work…I´m new to ruby and want to know if anyone can help me
If I type just “instances.each” it delete the complete component. Is the a way to say in Ruby something linke: “check each component in model, if there is an instance name -> delete it”Hope you understand my nearly perfect English.
I uploaded a example file.Thanks for help
test.skp (266.6 KB)
Posts: 5
Participants: 2
@denis_bolomier wrote:
Hi All,
Since one hour I’m looking for a clear explanation about setting cursor in ruby API.
Inside my tool , I got this line:iConeDeLoutil = "RTE_64_yes.png" cursorDir = File.join(File.dirname(__FILE__), "..", "icon") cursor_path = File.join(cursorDir, iConeDeLoutil) if cursor_path @cursor_id = UI.create_cursor(cursor_path, 0, 64 ) end
But on my Mac book pro, Sketchup pro 2018, the icon appear on if the icon is 64x64px.
and its doen’t work on PCif I switch on 32x32 , its work on pc but not on mac.
what is the best solution to manage cursor and cursor file ?
Thanks
Posts: 1
Participants: 1
@mbrown1171 wrote:
Hi. I’m new to Ruby. I’m just trying to cut my teeth on something simple. I want to add a new instance of a component to my model and I want to add it 12 inches from the current selection on the x axis and on the same y and z axes.
Here’s a sample of my code. I don’t really think that it’s as easy as this portion of code… ([selection.x+12,selection.y,selection.z])
I just wrote that in to illustrate what I’m attempting.
Basically it’s just about trying to create a new instance of a component relative to a selection.
model = Sketchup.active_model
entities = model.entities
selection = model.selection
definitions = model.definitions
selection = entities.add_instance(definitions[0],[selection.x+12,selection.y,selection.z])Thanks for your help
Posts: 10
Participants: 3
@GregIII wrote:
I wonder if someone can help me with a simple “animation”.
In fact I do not want to move anything.
I just would like to show(or hide) my component instances one by one with a small delay.My model includes several hundreds of my special bricks.
I need to show these bricks one-by-one (as one would build a house by these "LEGO like) bricks).
I mean on this that the first “scene” would be empty.
Second “scene” would display only the first brick,
the third “scene” would show one more brick, and so on.
I do not want to move anything.
Only make them visible one-by-one.That means I would need the same number of scenes
as the number of bricks (500-1000)
and I think this is way much more than SU Scenes can handle.
That is why I use ruby script instead.However my code below just does not work.
(I use Sketchup Pro 2018)It works for the first few bricks than it waits and displays the final state .
I understand that this is something to do with asynch feature of Sketchup.
But can not find solution using Google.(I’ve a sample model too, but don’t know how to upload.)
I would appreciate any help.
model = Sketchup.active_model # OK defns = model.definitions view = model.active_view defns.each{|defn| defn.instances.each{|inst| model.start_operation('Wall display', true) inst.visible = false Kernel.sleep(1.0) # a second view.invalidate # view.refresh model.commit_operation } }
Posts: 9
Participants: 5
@denis_bolomier wrote:
Hi,
I made a tool in ruby. on mac mac book pro OSX with sketchup pro 2018, the line of my tool are cut with an invisible section plane like the cliping box of the graphic card.
lines.each{|line| # puts "__#{line.inspect}__" view.draw_lines(line[0],line[1]) }
Is theire any solution?
Posts: 3
Participants: 3
@rvamerongen wrote:
Hello everybody,
Is that possible, to have an image in the menu item? Is there a hack to do this in ruby.
I don’t see any mention on the web.
Posts: 3
Participants: 3
@rvamerongen wrote:
If you go to ruby.sketchup.com and you type for example purge there is no result.
This is a longstanding flaw.
Request; Why no decent search engine?Now i have to use site:ruby.sketchup.com and i can type the search words. But it is an silly way to search.
Posts: 3
Participants: 3
@gabor.konstanzer wrote:
Hi, my question would be the following. What should i do, if i want to make a request on a URL that needs the basic auth header to give back HTML result? I’m trying to use the UI::HTMLDialog.
Thanks,
Gabor
Posts: 2
Participants: 2
@medeek wrote:
One of my html menus is getting rather complex and as a result the Ruby code that talks to it is also getting more complex. My concern is that by defining too many callbacks it will cause problems. Is there any practical limit on the number of callbacks you can define?
Posts: 4
Participants: 3
@phillippe wrote:
I’m creating a custom tool and it would be useful for end users to see previews (similar to SU’s circle and rectangle tools) of the geometry they’re about to create. I want the users to immediately know which face they’re drawing on, but depending on how zoomed in/out they are, the preview can be too large/small to see. How can I draw them so they scale accordingly at different zoom levels?
For clarity:
How I want it to behave (SketchUp's Circle Tool)
How it currently does
BTW, I’m still getting used to 3d graphics programming and familiarizing myself with SU’s API, so please excuse me if this is pretty basic.
Posts: 3
Participants: 2
@medeek wrote:
What is the quickest and most inexpensive way to search for a group or groups within an existing group given only the sub- groups unique name?
My first crack at it would be, based on some of my recent code:
@maingroup = Sketchup.active_model.selection group_list = @maingroup.entities.grep(Sketchup::Group) specific_group_list = group_list.find_all { |e| e.name =~ /UNIQUE_NAME_GOES_HERE/ }
Posts: 9
Participants: 2
@Mickael wrote:
Hello,
I am working with files made with another software (FME), which can handle sketchup layers, but only partially : faces are set to the wanted layer, but all edges are set to Layer0.
So, is their a way to retreive edges connected to “layered” faces and set them into the same layer ? And to create a group from thoses faces & edges ?
I have been looking to many posts, running several tests, but I still havn’t figured it out, so any help on this would be appreciated
EDIT : Thanks to DaveR explanations, I am now looking for a way to :
1°) Create faces + edges groups from my current layers (which only “contains” faces),
2°) Assign those groups to their related layer,
3°) Move all primitive geometry to Layer0.
Here is the kind of file I am working on (generated by FME) :
groups_layers_test_file.skp (400.6 KB)
Posts: 10
Participants: 4
@jb_Trystram wrote:
Hello,
I’m working on Plug-ins that use DC and i get often this error. this is an error from su_dynamiccomponents and i can’t do nothing again, not even understand what’s going on. it makes the component window not showing the parameter.Error: #<NoMethodError: undefined method
deleted?' for #<Sketchup::Model:0x007fc7fd95c938>> /users/jbt/library/application support/sketchup 2018/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_overlays.rbe:212:in
block in pull_attribute_tree’
/users/jbt/library/application support/sketchup 2018/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_overlays.rbe:212:indelete_if' /users/jbt/library/application support/sketchup 2018/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_overlays.rbe:212:in
pull_attribute_tree’
/users/jbt/library/application support/sketchup 2018/sketchup/plugins/su_dynamiccomponents/ruby/dcclass_v1.rbe:245:inblock in show_dialog' SketchUp:1:in
call’
Posts: 7
Participants: 3
@codydjango wrote:
Hello – I’m working on a sketchup extension, and I’d like to open a onboarding window on successful installation. I don’t want the window to open every time the extension is loaded – only when it’s first installed. I haven’t seen any documentation for exposed “hooks” that I could tie into. I might have missed something, as I’m quite new to sketchup development.
Thanks so much!
Posts: 4
Participants: 3
@medeek wrote:
Not sure if such a thing is possible but here goes…
I’m utilizing an HTML dialog within a Tool. As per SU standard practice when you hit the space bar it jumps you out of the tool (exits), however the HTML dialog is still left open. Is there a way to auto-close the HTML window when the tool is terminated? Note that I do not want to close the HTML dialog window on reset, just when the tool is exited.
I’ve looked around a bit for an answer but I did not turn up anything. This question is above my pay grade.
Posts: 4
Participants: 2
@medeek wrote:
I’m trying to apply textures (materials) to various faces of an LVL board.
I am trying to apply a specific material to the edge face of the board.
My initial code looks like this:
group1faces = entities1.grep(Sketchup::Face) group1faces[2].material = @Lvl_mat group1faces[3].material = @Lvl_mat
The problem is to determine which faces are the narrow face of the board. They are always less than 2" in width and they are always oriented on the X-Y plane.
I’m sure I’ve seen a similar algorithm or Grep expression that can do this sort of thing but again my search came up empty.
Posts: 4
Participants: 4
@haiquan wrote:
Hello, in the sketchup ruby API, can I use the ruby code to simulate a mouse click on the sub-menu in menu?
thank you very much!
Posts: 3
Participants: 3