Hello dear Fredo. Can I ask you to make a small edit to your plugin? Could we have more than 2 (3,4,5...N) scale planes in the plugin?
Latest posts made by kostiaarh
-
RE: [Plugin][$] FredoScale - v3.6a - 01 Apr 24
-
RE: [Plugin] 2D Tools
I would like to ask for help with a small change to the 2D Fillet code.
I do a little woodworking (cabinet) and would like some tools to make my job easier. I tried to change the code myself, but my knowledge in programming is very insufficient). So I am asking you to help me. Also, let me say up front that I know of other chamfering and rounding tools, but they don't work for me for various reasons. They do not create a solid arc or curve, and the chamfer function has no methods to set different chamfer distances.
Now about the code. I would like to have a simple 3D Fillet/Chemfer. The tool should work with objects (group or component) regardless of nesting level. I added the code to the onMouseMove method and now it works.def onMouseMove(flags, x, y, view) ### ph = view.pick_helper ph.do_pick(x,y) @poss_edge = ph.picked_edge ### center_ip = Sketchup;;InputPoint.new center_ip.pick(view, x, y) view.model.active_path = center_ip.instance_path.valid? ? center_ip.instance_path ; nil if @state==0 if @alt ### chamfer ..................
But here there is a problem) How to remove residual geometry? Look at the picture. Am I understanding this correctly? I need to find the residual face and push it to the parallel face. right? Or maybe there are other ways to do it differently?
-
Fix and improve the code
Please help me to fix and improve the code.
I have a problem with calculating the dimensions of scaled objects and objects rotated relative to global axes.
First, the code was written, which uses the method of calculating the dimensions of the object by the points of the edges (thanks for the tip from the official Sketchup forum). And this method works well with objects rotated relative to global axes.
Here is the code.
This code calculates dimensions correctly in rotated relative to global axes, but incorrectly in scaled objects.class TestTool def initialize @ip = Sketchup;;InputPoint.new @hovered_inst = nil end def onMouseMove(flags, x, y, view) @ip.pick(view, x, y) @ph = view.pick_helper @in_path = @ip.face ? @ip.face.parent.instances ; nil @hovered_inst = @in_path&.first if @in_path view.invalidate end def draw(view) @ip.draw(view) if @ip.valid? view.draw_points(@ip.position, 40, 5, "red") if @ip.valid? view.tooltip = @hovered_inst&.name if @hovered_inst.is_a?(Sketchup;;Group) || @hovered_inst.is_a?(Sketchup;;ComponentInstance) entity = @hovered_inst edges = entity.definition.entities.select { |e| e.is_a?(Sketchup;;Edge) } points = edges.flat_map { |e| [e.start.position, e.end.position] } min_x, max_x = points.minmax_by { |p| p.x }.map(&;x) min_y, max_y = points.minmax_by { |p| p.y }.map(&;y) min_z, max_z = points.minmax_by { |p| p.z }.map(&;z) length = (max_x - min_x) * 25.4 width = (max_y - min_y) * 25.4 thickness = (max_z - min_z) * 25.4 dimensions = [length, width, thickness].sort length = dimensions.last width = dimensions[1] thickness = dimensions.first area = (length * width / 1000000).round(2) text = "Ім'я; #{entity.name}\nДовжина; #{length.round(1)} мм\nШирина; #{width.round(1)} мм\nТовщина; #{thickness.round(1)} мм\nПлоща; #{area} м.кв." draw_text_with_bigger_font(view, [20, 20], text, 16) end end def draw_text_with_bigger_font(view, position, text, font_size) options = { color; "red", font; "Arial", size; font_size, bold; true, align; TextAlignLeft } view.draw_text(position, text, options) end end Sketchup.active_model.select_tool(TestTool.new)
But then I ran into a bug and found that it was calculating the dimensions of the scaled object incorrectly. I tried to fix it in the code.
Here is the code.This code correctly defines dimensions in scaled groups, but incorrectly in rotated relative to global axes.
### In the updated code, a new transform_point method was added, which applies the transformation matrix of the object to the specified points. ### This method is used to transform the vertex coordinates of the edges before dimensioning. class TestTool def initialize @ip = Sketchup;;InputPoint.new @hovered_inst = nil end def onMouseMove(flags, x, y, view) @ip.pick(view, x, y) @ph = view.pick_helper @in_path = @ip.face ? @ip.face.parent.instances ; nil @hovered_inst = @in_path&.first if @in_path view.invalidate end def draw(view) @ip.draw(view) if @ip.valid? view.draw_points(@ip.position, 40, 5, "red") if @ip.valid? view.tooltip = @hovered_inst&.name if @hovered_inst.is_a?(Sketchup;;Group) || @hovered_inst.is_a?(Sketchup;;ComponentInstance) entity = @hovered_inst edges = entity.definition.entities.select { |e| e.is_a?(Sketchup;;Edge) } transformed_points = edges.flat_map { |e| transform_point(entity.transformation, e.start.position, e.end.position) } min_x, max_x = transformed_points.minmax_by { |p| p.x }.map(&;x) min_y, max_y = transformed_points.minmax_by { |p| p.y }.map(&;y) min_z, max_z = transformed_points.minmax_by { |p| p.z }.map(&;z) length = (max_x - min_x) * 25.4 width = (max_y - min_y) * 25.4 thickness = (max_z - min_z) * 25.4 dimensions = [length, width, thickness].sort length = dimensions.last width = dimensions[1] thickness = dimensions.first area = (length * width / 1000000).round(2) text = "Ім'я; #{entity.name}\nДовжина; #{length.round(1)} мм\nШирина; #{width.round(1)} мм\nТовщина; #{thickness.round(1)} мм\nПлоща; #{area} м.кв." draw_text_with_bigger_font(view, [20, 20], text, 16) end end def transform_point(transformation, *points) points.map { |pt| transformation * pt } end def draw_text_with_bigger_font(view, position, text, font_size) options = { color; "red", font; "Arial", size; font_size, bold; true, align; TextAlignLeft } view.draw_text(position, text, options) end end Sketchup.active_model.select_tool(TestTool.new)
I try to combine these two methods, but nothing works). What am I doing wrong?
I will be very grateful for tips. -
RE: [Plugin][$] RoundCorner - v3.4a - 31 Mar 24
@dave r said:
Do you mean having the series of straight edges welded together so they are recognized by Sketch as arcs or curves? If so, that could be very useful. Currently I make that happen by runing Eneroth Auto Weld after using Round Corner or Fredo Corner.
Exactly
-
RE: [Plugin][$] RoundCorner - v3.4a - 31 Mar 24
@dave r said:
@kostiaarh said:
I see that roundcorner and fredocorner build arcs with just segments, not "arc". Why is this so?
This isn't a Round Corner thing. It's the way SketchUp represents arcs and curves. You've been using SketchUp long enough that you would know this.
Yes, I know about it.) Perhaps it is the difficulty of translation). The question was more about whether we could have a plugin from Fredo in the future that would create a "arc/curve" instead of individual segments.
-
RE: [Plugin][$] RoundCorner - v3.4a - 31 Mar 24
First, thank you for such great plugins. Question: Can we build real arcs instead of simulating them with segments? I see that roundcorner and fredocorner build arcs with just segments, not "arc". Why is this so?
-
RE: Radial menu inside SU
@rich o brien said:
@kostiaarh said:
@Rich O Brien plugin Pie for SketchUp does not work Sketchup 2023
Yeah, I'm aware of it.
We will wait for updates?
-
RE: Radial menu inside SU
@Rich O Brien plugin Pie for SketchUp does not work Sketchup 2023
-
RE: Plugin Search
@dave r said:
Sam D Mitch has withdrawn his extensions and it wouldn't be right to share them. You might look at S4U Align from the SCF Plugin Store or Curic Align from the Extension Warehouse.
Thanks Dave R. Yes, others have suggested a solution to me too using Curic plugins. Curic Reset Rotation + Curic Space + Curic Align