How about the wait cursor, is there a way to display that?
Posts made by timc
-
RE: Use Sketchup default cursors
-
RE: Determine zoom level through API
Thank you thomthom, that is exactly what I was looking for.
-
RE: Determine zoom level through API
This is the code I'm using
#This is what I have in the draw method of my tool def draw(view) #@temp = the current mouse location. it is set in the mousemove method. @normal = view.camera.direction @pts_circle = circle_points(@temp.position, @normal, 10, 24) view.drawing_color = "blue" view.draw_polyline(@pts_circle) end #This is a function I found that creates the points needed to draw a circle def circle_points(center, normal, radius, numseg) # Get the x and y axes axes = Geom;;Vector3d.new(normal).axes xaxis = axes[0] yaxis = axes[1] zaxis = axes[2] xaxis.length = radius yaxis.length = radius # compute the points da = (Math;;PI * 2) / numseg pts = [] for i in 0..numseg do angle = i * da cosa = Math.cos(angle) sina = Math.sin(angle) vec = Geom;;Vector3d.linear_combination(cosa, xaxis, sina, yaxis) pts.push(center + vec) end # close the circle pts.push(pts[0].clone) pts end
If I use the mouse wheel to zoom while the tool is active the circle stays at a diameter of 10, so it appears larger if I zoom in and smaller if I zoom out.
-
Determine zoom level through API
Is there a way to determine the zoom level through the Sketchup API?
I am trying to emulate the way the circle drawing tool displays a circle around the current mouse position. I can display a circle with ease, but the circle gets larger as I zoom in. I want the circle to remain the same size despite how far I zoom in or out.
Any help would be appreciated, Thanks.
-
Use Sketchup default cursors
I was playing around with a new tool, and was wondering if there is an easy way to use Sketchup cursors, or do I have to use custom cursors?
For example I want to use the pencil cursor in my own tool. Are there constants setup that I can pass to UI.set_cursor()?
-
RE: Problem outputting arc to dxf file
I could change it so it recalculates the end_angle as well, that way I would not have to worry what SketchUp says the angle is. But I think I have bigger issues than that.
-
Problem outputting arc to dxf file
I have written a script that outputs simple 2D drawings to a dxf file, but I am having some trouble with arcs. Sometimes they output fine, other times they are either facing the wrong way or in the wrong location.
This is the code I'm using to output arcs. The start_angle of ArcCurves was always 0.0 so I created the get_new_angle function to calculate the angle of a line from the center of the arc to the start point, I use that as the start_angle and add it to end_angle.
Any help with this would be appreciated, Thanks
def dxf_output_arc(curve, layername) #curve is an ArcCurve object #layername is the name of the layer the object is on points = curve.center new_angle = get_new_angle(points, curve.vertices[0].position) $dxf_file.puts( " 0\nARC\n8\n"+layername+"\n") $dxf_file.puts(10.to_s+"\n"+(points.x.to_f * $conversion_factor).to_s)#x $dxf_file.puts(20.to_s+"\n"+(points.y.to_f * $conversion_factor).to_s)#y $dxf_file.puts(30.to_s+"\n"+(points.z.to_f * $conversion_factor).to_s)#z $dxf_file.puts(40.to_s+"\n"+(curve.radius.to_f * $conversion_factor).to_s)#radius $dxf_file.puts(50.to_s+"\n"+new_angle.to_f.to_s)#start_angle $dxf_file.puts(51.to_s+"\n"+((curve.end_angle.degrees + new_angle).to_f).to_s)#end_angle end def get_new_angle(center, point) #This function returns the angle of a line return Math;;atan(((center.y.to_f - point.y.to_f)/(center.x.to_f - point.x.to_f))).to_f.degrees.abs end
-
RE: Create faces in script
find_faces was exactly what I was looking for. Thanks,
-
Create faces in script
I am working on a script that creates 3D objects, but faces are not being created when edges intersect. What do I have to do to get faces to be created automatically?
-
Where is the best place to get help?
I often find myself writing ruby scripts to expand the functionality of SketchUp, but as I am not familiar with Ruby or the SketchUp API it is often difficult.
I have posted a few times to this forum, but have not really found much help. Where is the best place to get help writing scripts/tools for SketchUp?
I use this site a lot for API help http://code.google.com/apis/sketchup/docs/index.html
-
Draw angle dimensions
I am working on a script that will add an angular dimension, so far I can select two edges that share a common point, and determine the angle they create.
Now I want to draw an arc between the two lines, I want this arc to move along the lines (similar to how the dimension tool does) until the user clicks to set the proper location.
When complete the tool will work as follows.
- The user will select the first edge.
- The user will select a second edge that intersects the first edge.
- A temporary arc should slide along the lines (following the mouse) until the user clicks to set the location.
- The arc and dimension text will be added to the model.
Edit:
The script is coming along.
I can draw an arc based on the angle, and have it move as I move the mouse. The next step will be to trim or extend the arc, to make sure the start and end point are always on the selected edges.I also have to adjust the code so the edges can be selected in a counter-clockwise direction as well as a clockwise direction.
If anyone has code examples to help me, I would appreciate any assistance.
-
RE: Output arcs to dxf format
I'm getting closer. It turns out that ArcCurve.start_angle is always 0.0, so I made a function that finds the actual start anlge, I then add that to the end angle for output.
def get_new_angle(center, point) #center is the center point returned by AcrCurve.center #point is the start point of the arc returned by ArcCurve.vertices[0].position return Math;;atan(((center.y.to_f - point.y.to_f)/(center.x.to_f - point.x.to_f))).to_f.degrees.abs end
Now the problem is arcs on the y axis are not correct.
-
RE: Output arcs to dxf format
I guess I should have said that I already convert it to degrees.
I think I am losing something in the transition from sketchup to dxf, but I'm not sure what. It seems like it should be a straight forward transition center point = center point, radius = radius, angles = angles, but it is turning into a real headache.
-
RE: Output arcs to dxf format
Chris,
The only problem I'm having is getting the correct start and end angle of the arc, the ArcCurve.start_angle, and ArcCurve.end_angle are not giving me the correct values.I'm currently trying to determine these angles myself using the start point and end point of the arc, but I'm having trouble getting it to work consistently.
-
RE: Output arcs to dxf format
To get the proper layer name for each entity you have to do something like this.
model = Sketchup.active_model entities = model.entities layername = entities[entity_index].layer.name
or in a for each loop
model = Sketchup.active_model entities = model.entities entities.each |entity| layername = entity.layer.name end
I have seen the script you mentioned, but it outputs arcs as a series of lines. I am trying to output arcs as arcs.
-
Output arcs to dxf format
I am writing a script that allows me to output simple 2D drawings to dxf format, but I am having some trouble with arcs. I can output lines and circles fine but my arcs do not have the correct starting and ending angles, the arc always opens down despite it's orientation in the model.
How can I correctly output arcs in dxf format?
[Edit:]I should specify I want to output the arcs as arcs, not a series of lines.