nope, I have not copied, create the object there.
There are also problems when making copies when it is inside a group or component nonorthogonal...
is very strange behavior you describe
(google translator)
nope, I have not copied, create the object there.
There are also problems when making copies when it is inside a group or component nonorthogonal...
is very strange behavior you describe
(google translator)
Has anyone reproduced this error?
Hi all, I am watching an error when I try to create a group or component inside an nonorthogonal instance
I do not know if this behavior is known and I do not know if it has been reported to Trimble..
(I tried it on Sketchup 8 2014)
This is just a test code that I draw from other code where it was necessary to use @variables, (I forget to delete the unnecessary). This is a slightly better version:
def change_text(sel,text,view)
if (sel.is_a?(Sketchup;;Group) || sel.is_a?(Sketchup;;ComponentInstance))
text.set_text "Position; #{sel.transformation.origin}"
text.point = sel.bounds.center
else
text.set_text ""
end
view.invalidate
end
def show_textinfo(time)
t = Time.now
mod = Sketchup.active_model;
sel = mod.selection[0];
ent = mod.entities;
view = mod.active_view
tools = mod.tools;
mod.start_operation("position",false,false,true)
text = ent.add_text "", [0,0,0]
my_id = UI.start_timer(0.1, true) {
Sketchup.send_action "selectSelectionTool;" unless tools.active_tool_id == 21022
unless sel == mod.selection[0]
sel = mod.selection[0]
change_text(sel,text,view)
end
(UI.stop_timer(my_id); text.erase!; mod.commit_operation) if Time.now-t > time
}
end
show_textinfo(25) # will run for 25 seconds
however is better the prospect of creating a tool
(google translator)
probably also will need to add dictionaries to your "nodes" with something like
entity.set_attribute "dictionaryName", "keyName", ["data", 23, "house"]
another option using start_timer and stop_timer
time = 60 # seconds (will be deactivated in x seconds)
t = Time.now
mod = Sketchup.active_model
ent = mod.entities
view = mod.active_view
@text = ent.add_text "", [0,0,0]
@my_id = UI.start_timer(0.1, true) {
sel = mod.selection[0]
if (sel.is_a?(Sketchup;;Group) || sel.is_a?(Sketchup;;ComponentInstance))
@text.set_text "Position; #{sel.transformation.origin}"
@text.point = sel.bounds.center
else
@text.set_text ""
end
view.invalidate
(UI.stop_timer(@my_id); @text.erase!) if Time.now-t > time
}
this code does what you need (if I understood well)
just need to add the details that all code must have (star_operation, stop_operation put in a definition, ...)
(google translator)
Anton_S your code is very interesting (highlight_picked_body.rb), I have never used Start and stop operation inside a custom tool, I like the result, I am studying this code
thank you very much Jolran, view.screen_coords
is very useful,
Initially I did this:
class DibujaCubo3d
def activate
@size = 60
@tr = Geom;;Transformation.new([20,10,30])
end
def transformar(pts,axis_num)
pts = pts.map{|p| [p.z,p.x,p.y]} if axis_num == 0
pts = pts.map{|p| [p.y,p.z,p.x]} if axis_num == 1
pts = pts.map{|p| p.transform! @tr}
end
def draw_square(view, axis_num, size, alto)
pts = [[0,0,alto],[size,0,alto],[size,size,alto],[0,size,alto]]
pts = transformar(pts,axis_num)
view.drawing_color = [0,0,0]
view.draw GL_LINES, pts
view.drawing_color = [0,255,0]
view.draw GL_QUADS, pts
end
def draw(view)
3.times{|i| draw_square(view, i, @size, 0)}
3.times{|i| draw_square(view, i, @size, @size)}
end
end
Sketchup.active_model.select_tool DibujaCubo3d.new
and this is the best that I can get for now
class DibujaCubo
def activate
@size = 60
@tr = Geom;;Transformation.new([20,10,30])
end
def transformar(view,pts,axis_num)
pts = pts.map{|p| [p.z,p.x,p.y]} if axis_num == 0
pts = pts.map{|p| [p.y,p.z,p.x]} if axis_num == 1
pts = pts.map{|p| view.screen_coords(p.transform!(@tr))}
end
def points_square(view, axis_num, size, alto)
pts = [[0,0,alto],[size,0,alto],[size,size,alto],[0,size,alto]]
pts = transformar(view,pts,axis_num)
end
def draw_shapes(view, tipe, size, color)
view.drawing_color = color
3.times{|i| view.draw2d tipe, points_square(view, i, size, 0)}
3.times{|i| view.draw2d tipe, points_square(view, i, size, @size)}
end
def draw(view)
draw_shapes(view, GL_QUADS, @size, [0,255,0])
draw_shapes(view, GL_LINES, @size, [0,0,0])
end
end
Sketchup.active_model.select_tool DibujaCubo.new
always shown ahead of all geometry!
thanks for answering, I do not mean to have two tools running simultaneously, what I want to do is create a clone of the scale tool to add additional features, I do not understand is how to draw a cube in front of sketchup instances, or draw a cube in 2d consistent with the perspective
thanks for replying, I mean that the OpenGL geometry not hide because of the entities in the model,
use 2d drawings is an option but it seems a bit complicated for something with back and front part, in my case the object has shape of a cube
(sorry for any errors in translation)
Hi all, I want to ask how can I bring to the front drawing openGL?,
something like this:
I do not know how to do this, in advance I appreciate your help
(google translator)
Dan thanks for replying, I found a recommendation yours here
which led me to the article by thomthom
There are extensions to the base classes in SketchUp’s Ruby API which often new SketchUp plugin developers overlook. If you aren’t aware of them you might find yourself reinventing many…
Procrastinators Revolt! (www.thomthom.net)
I only have problem for receiving angles values with comma as decimal separator, then I am forced to use the following
text_input.sub!(',','.') text_input.to_f.degrees
I do not know if there is a better method
hi all, I want to ask If at the SketchUp API
Is there a way to interpret a length inserted through the VCB,
as when the translation tool is used?
for example: when the user is working on fractional inch format
and enter something like 10 1/2 or you're working in centimeters and enter something like 15.3 cm
my question is:
Does the API has some input interpreter for a length or should be built?
Thanks in advance for your help
(google translator)
sorry for my silly mistake, thanks Sdmitch
hi all, I'm playing around with the method closest_points
and I'm getting unexpected results, this is the code:
line1 = [Geom::Point3d.new(10,10,10),Geom::Point3d.new(1,0,0)] line2 = [Geom::Point3d.new(20,30,50),Geom::Vector3d.new(2,1,0)] r = Geom.closest_points line1,line2
with this I expected the two closest points between the two lines, in my case should be
(-20,10,10),(-20,10,50)
but I get
(43.7681, 47.5201, 47.5201),(46.0225, 43.0113, 50)
Am I missing something?
by the way, if any of the two lines coincide with the coordinate axes I get the expected result
(google translator)
Hello, I am developing a tool and I find undesired behavior, when I select my tool, I hold down the left mouse button and I approach a limit of viewport, the position of the view changes (click the image to see the gif)
I would like to control this behavior, does anyone have any idea how?
I have thought that maybe I can use onMouseLeave
but I suspect it would not work
thank you very much in advance for the help
(google translator)
is a shame..., I hope this to be improved for the next version of Sketchup
(Google translator)
Jim thank you very much for the answer, it is what I needed
I have another question related to text, how I can increase the font size when use draw_text
?
Create text in the viewport
Hi, I have a question, how to create text in the viewport using ruby? Like that (sometimes) appears when using SketchyPhysics
This text does not disappear by selecting different tools, so it does not seem to be done with draw_text
in advance I appreciate your help
.
I have the following error
I use windows 7 and tried this plugin in sketchup 8 and sketchup 2014