Thanks for the reply sdmitch, give me a first clue
what worries me is that the user of the plugin do this and generate a bug splat on, I would like in this case simply do not tube, but do not understand how to calculate the minimum length allowed for this case
Posts
-
RE: Help with .followme
-
RE: Help with .followme
Thanks Dan, I modified my code.
My problem persists, someone can see the problem? -
Help with .followme
Hi guys, I am making a plugin where I need to use
.followme
and I'm having bug splat with some curves, an attached two example curves that give me problems
curves
here a fragment of my codemodel = Sketchup.active_model sel = model.selection ent = model.entities selec = [] selec.clear sel.each{|ob| selec.push(ob) if ob.is_a?(Sketchup;;Edge)} if selec.size == 0 UI.messagebox "Please select a Curve" return end radio_tubo = 10.0.cm lados_tubo = 8 pts=[] pts.clear pts=selec[0].vertices.collect{|v| v.position} if Sketchup.version.to_f < 7.0 model.start_operation("Draw tube") else model.start_operation("Draw tube", true) end grupo = ent.add_group entities = grupo.entities normal_cir = (pts[0].vector_to pts[1]).normalize circle = entities.add_circle pts[0], normal_cir, radio_tubo, lados_tubo cara = entities.add_face circle cara.reverse!.followme selec #selec.each{|edge| edge.erase!} model.commit_operation qq="OK"
I try to test the plugin TubeAlongPath.rb with radius = 10 cm and also the bug occurs
plugin
I've noticed that with smaller r no problem (for example r = 2 cm)I do not know how to fix this, in advance thank you for your help
(google translator)
.
-
RE: OnScreen GUI Toolkit
I would like to do this, to make a inputbox made with OpenGL, could you please show an example of how to do this?
-
RE: OnScreen GUI Toolkit
with this would it be possible to create a dialog that allows the user to enter a number?
(google translator)
-
RE: Questions about realization of tools
is true, on several occasions have been very frustrating these examples
-
RE: [Plugin] Model2GCode V0.5 - released 04.02.13
this is very interesting! move from a sketchup model to a model in my hands is something I have long dreamed.
This is a wonderful job!
(google translator) -
RE: Questions about realization of tools
Thom thank you very much, really I could not understand how to do this
-
RE: Questions about realization of tools
@dan rathbun said:
A ray is a two element array containing a point and a vector [ Geom::Point3d, Geom::Vector3d ]. The point defines the start point of the ray and the vector defines the direction.
Thanks Dan, I now understand better
@dan rathbun said:
Perhaps you wish to use model#raytest ?
It can return objects it hits.
View#pickray() does not, by itself, "hit" anything, but could be used for the 1st argument to Model#raytest().I've never used it, looks interesting I'll give a look.
For now solve the problem using the parametric form of the line;x = x0 + ta
y = y0 + tb
z = z0 + t*cin my case a, b, c is associated with
Geom :: Vector3D
(parallel to the line)
and x0, y0, z0 is associated withGeom :: Point3D
(content in the line)
the intersection with plane z=0 (XY plane), for example would beray = view.pickray x, y #ray[0] -> Point3D, ray[1] -> Vector3d if ray[1].z.abs>0 z1 = 0 #Interesting plane t1 = (z1-ray[0].z)/ray[1].z x1 = ray[0].x + t1*ray[1].x y1 = ray[0].y + t1*ray[1].y end #x1,y1,z1 are coordinates of the point of intersection with the plane
For the other two planes is very similar, although in my case I want to compare the different distances of the planes to the point of "eye" for this I did the following
ray = view.pickray x, y if ray[1].z.abs>0 z1 = 0 #Interesting plane t1 = (z1-ray[0].z)/ray[1].z d1 = (t1*ray[1].x)**2 + (t1*ray[1].y)**2 + (z1-ray[0].z)**2 end #d1 is the square of the distance from the eye to the plane
-
RE: Questions about realization of tools
Guys, how to remove an observer of tools? I created an observer slightly modifying the example shown in the API
class MyToolsObserver < Sketchup;;ToolsObserver def onActiveToolChanged(tools, tool_name, tool_id) if tool_id == 21100 puts "tool x" end end end Sketchup.active_model.tools.add_observer(MyToolsObserver.new)
I thought you could with something like this:
Sketchup.active_model.tools.remove_observer(MyToolsObserver)
What is the correct way to remove this observer?
-
RE: Questions about realization of tools
I give up, I can not understand how to use
view.pickray x, y
for the intersection with the XY, XZ and YZ, and thereby be able to guide a tool, really I can not see how this is doneI could only understand that returns two points, one coincides with the point of view and the other (I think) is a vector pointing toward the cursor, but do not understand how to use this to get the intersection with the respective flat front or behind me
-
RE: Questions about realization of tools
@thomthom said:
Threads doesn't work well in SketchUp Ruby. It's Ruby 1.8 and they are not true threads.
I did not know this , thanks
-
RE: Questions about realization of tools
@thomthom said:
Got a bare bone example that shows this slowness?
Yes,
require 'Win32API' Thread.new { x=1 while (x<1000) do getCursorPos = Win32API.new("user32", "GetCursorPos", ['P'], 'V') lpPoint = " " * 8 # store two LONGs getCursorPos.Call(lpPoint) x, y = lpPoint.unpack("LL") # get the actual values coor_mouse = " #{x}, #{y}" Sketchup;;set_status_text coor_mouse, SB_VCB_VALUE end }
Note : to see how slow returns coordinates, should be small the Sketchup window and put the cursor outside it, to stop the program move the cursor to the right until x >1000
(Google Translator)
-
RE: Questions about realization of tools
@jim said:
getExtents
, maybe.thank you very much Jim!, this solved the problem, cost me a bit to understand how to implement it, but it goes
@thomthom said:
What if you also hook into the event callback of when the cursor moves? Ignoring the Tool class' events?
I tried but it works very slow when the cursor is outside the window of Sketchup,
-
RE: Questions about realization of tools
@thomthom said:
#1. You make special cases for that. When you don´t hit any geometry, Make a pickray and see if it intersects any of the XY, XZ, YZ planes.
Thomthom thank you very much!, That's what I'll do
@thomthom said:
#2. Don´t think you can with just pure Ruby. The native tools do that because they are done in C++ and capture the mouse. Unfortunatly there is no way to capture the mouse from the Ruby API.
It is a pity. I thought this might serve me
require 'Win32API' getCursorPos = Win32API.new("user32", "GetCursorPos", ['P'], 'V') lpPoint = " " * 8 # store two LONGs getCursorPos.Call(lpPoint) x, y = lpPoint.unpack("LL") # get the actual values coor_mouse = " y = #{x}, x = #{y}"
but at the end I think can not because
onMouseMove
only respond within the drawing window.any suggestions to prevent my tool display incomplete?
.
-
Questions about realization of tools
Hi, I'm trying to create a tool and I have arisen various questions in the process.
One question is how orienting a tool as shown in the image? since there are no faces on which to place the tool anddegrees_of_freedom
is in this case = 3Another question I have is, How to detect the position of the tool outside the edit window?, (as happens with the orbit tool).
and the other question is, what command I can use for prevent my tool this cropped and disappears only when I leave the drawing window?
sorry for these "gif" can be a bit annoying but needed to illustrate my questions
(google translator) -
RE: Scale along custom axis
To do this simply could not use the version of the Pythagorean Theorem in 3d?
h² = a² + b² + c²
that gives the diagonal of a cube or any parallelepiped of right angles
(google translator) -
RE: Find the position of a group in the active context
I solved the problem, the key was to use "mod.edit_transform.origin"
I leave the code in case anyone needs it one daymod = Sketchup.active_model sel = mod.selection parert_origin = mod.edit_transform.origin entity_origin = sel[0].transformation.origin distance = entity_origin-parert_origin tr = mod.edit_transform.inverse distance.transform tr
-
RE: Find the position of a group in the active context
Sdmitch thank you very much, unfortunately the problem persists when I'm in the active context, I'm trying something with this
mod = Sketchup.active_model path = mod.active_path tr1 = Geom;;Transformation.new([0,0,0],[1,0,0],[0,1,0]) if path path.each{|entity| tr2 = entity.local_transformation tr1 = tr1*tr2 } end tr1.origin
It works, but to play around with this in the least expected moment this fails. If it always worked, I would do something like this then
mod = Sketchup.active_model sel = mod.selection path = mod.active_path tr1 = Geom;;Transformation.new([0,0,0],[1,0,0],[0,1,0]) if path path.each{|entity| tr2 = entity.local_transformation tr1 = tr1*tr2 } end origin_parent = Geom;;Vector3d.new(tr1.origin.to_a) ejex_o = sel[0].transformation.xaxis ejey_o = sel[0].transformation.yaxis center = sel[0].local_bounds.center tr3 = Geom;;Transformation.new([0,0,0], ejex_o, ejey_o) center_tr = Geom;;Vector3d.new((center.transform tr3).to_a) origin_group = Geom;;Vector3d.new(sel[0].transformation.origin.to_a) point = origin_group - origin_parent + center_tr point_tr = point.transform tr1.inverse
here I have gained the center of the group with respect to the coordinate system of the parent in the active context. The problem is that it only works well sometimes,
I do not understand how to fix this
(google translator) -
RE: Find the position of a group in the active context
thanks for replying, I saw this link, unfortunately I still do not understand how to solve my problem