But some other seem to be created as well, as we can see in my last
screenshot, after I replaced the origin. You can see small lines and dots
where the big lines lead to!
It’s like those elements are back on the x=0 plane while everything else is out around x≈1500m.
Here’s the source of the problem. The setup goes like this: Saskia imports a DWG that contains lines, arcs, circles, etc. She selects some of that geometry and then rotates it to the vertical plane. At the end of the rotation Sketchup will create new edges wherever lines overlap. As you can see from the GIF below things go horribly wrong when Saskia attempts to make a group from the edges. Any newly created end points (that are not included in the group) have an incorrect transformation applied to them.
We can demonstrate this with the ruby code below which mimics the operation of the Sketchup rotate tool. But be aware that this bug occurs for any type of transformation; move, scale, rotate, explode, anything that causes Sketchup to create new edges from the imported geometry.
module Rotate_Fail
model = Sketchup.active_model
ents = model.active_entities
#add a few edges and arcs
ents.add_edges(Geom::Point3d.new(0, 10, 0), Geom::Point3d.new(20, 10, 0))
ents.add_edges(Geom::Point3d.new(20, 0, 0), Geom::Point3d.new(20, 20, 0))
vector = Geom::Vector3d.new 0,0,1
vector2 = Geom::Vector3d.new 1,0,0
vector3 = vector.normalize!
centerpoint = Geom::Point3d.new(20, 0, 0)
ents.add_arc centerpoint, vector2, vector3, 17.55, 90.degrees, 180.degrees
ents.add_arc centerpoint, vector2, vector3, 15.0, 90.degrees, 180.degrees
UI.messagebox('Click to rotate', MB_OK)
#select the edges and arcs from the entities
sel = model.selection
sel.add(ents.to_a)
#rotate
point = Geom::Point3d.new(20, 0, 0)
vector = Geom::Vector3d.new(0, 1, 0)
angle = 90.degrees
tr = Geom::Transformation.rotation(point, vector, angle)
ents.transform_entities(tr, sel)
#intersect with self to create new edges
ents.intersect_with( false, IDENTITY, ents, IDENTITY, false, sel.to_a)
UI.messagebox('Do we have a problem here? Click to group', MB_OK)
#make a group the original edges, leaving the newly made edges behind
group = ents.add_group(sel.to_a)
#highlight the original edges
sel.add(group.entities.to_a)
end
Well done, I knew there was an explanation ! rather than… “of course it doesn’t work, it’s your fault your origin is too far”…
were you aware of that problem before ?
So, all the time I’ve been rotating up imported dwg geometry like this without seeing this phenomenon is because the rotated stuff is already grouped and SU doesn’t mess with the geometry intersections when I do that, perhaps?
I couldn’t make this happen with the Rotate tool + Group with lines and arcs I had drawn. Is there a bug in your Ruby?
I don’t think the intersect_with is being done correctly and is placing edges in unexpected places.
It has do be something about intersection, If I try reproducing the issue after intersecting the element that I then rotate and group, everything goes right. That is why you can’t reproduce it @Anssi with arcs and lines you drew in SU. They intersect automatically as you draw them, but not the ones imported from the dwg.
and @sWilliams is right, it’s not only the rotate tool, same thing happens when I just move & group. See for yourself :
For testing I’ve rolled your file back to SU 2015 and moved the geometry closer to the origin.
TR (2c) 2015.skp (116.7 KB)
In sketchup arcs and circles are a set of edges that share a pointer to an ArcCurve object. The problems stem from the management of these ArcCurve objects. If the user, by accident of software design, creates a group that includes only a portion of an ArcCurve’s edges the orphaned edges will be left in the parent’s entities collection with an incorrect transformation applied to them.
In addition: In SU 2015 if you then explode the bad group everything will appear to be fine but will cause a bugsplat on exit. In 2017 if you explode the bad group you’ll be left with a mess of incorrectly placed edges but no bugsplat. Using the model info-> statistics->fix problems will also leave the geometry a mess, likely with small edges abandoned a distance from the main geometry.
If your model has this problem you will see them in the results of the validity check.
Here’s the code for a small tool that will identify the ArcCurve errors. Paste this into the ruby console, activate the tool by clicking the Sick Arc toolbar icon and then click on a rogue Arc Segment. The diagnostics will appear in the ruby console.
Example output
edge = Edge:0x000000115ebf58
parent = ComponentDefinition:0x000000125e6110
edge start = Vertex:0x000000115eba30
edge end = Vertex:0x000000115eb850
curve = ArcCurve:0x000000115eb6e8
ArcCurve parent = ComponentDefinition:0x0000001240b1b0 is the wrong parent
curve edge count = 15
curve edges array = 1 Doesn’t match the curve edge count
Edge:0x000000115ebf58
I’m currently working on the code for a repair tool. In the mean time here’s the ruby.
# A small tool to investigate rogue arc segments resulting from importing and then grouping raw geometry
# Use the select tool to open the context you are interested in, then paste this code into the ruby console
module Sick_Arc
class InfoTool
def activate
puts 'sick arc inspector activated'
Sketchup.active_model.selection.clear
end
def onLButtonDown(flags, x, y, view)
puts '_____'
ph = view.pick_helper
ph.do_pick(x, y)
picked = ph.best_picked
model = Sketchup.active_model
model.selection.clear
(puts 'nil'; return) if !picked
sel = model.selection
sel.add(picked)
(puts 'Group'; return) if picked.is_a? Sketchup::Group
(puts 'Component'; return) if picked.is_a? Sketchup::ComponentInstance
edge = picked
puts 'edge = ' + edge.to_s[12..-2]
puts 'parent = ' + edge.parent.to_s[12..-2]
puts 'edge start = ' + edge.start.to_s[12..-2]
puts 'edge end = ' + edge.end.to_s[12..-2]
curve = edge.curve
if curve
parent = edge.parent
puts "\ncurve = " + curve.to_s[12..-2]
puts 'ArcCurve parent = ' + curve.parent.to_s[12..-2] + (' is the wrong parent' if parent != curve.parent).to_s
puts 'curve edge count = '+ curve.count_edges.to_s + (' :should not be 0' if curve.count_edges == 0).to_s
edges = curve.edges
puts 'curve edges array = ' + edges.size.to_s + (" Doesn\'t match the curve edge count" if curve.count_edges != edges.size).to_s
curve.each_edge {|e|
puts e.to_s[12..-2] + (' has a different parent' if parent != e.parent).to_s
sel.add(e)
}
else # edge
puts "\nedge start = %0.4f, %0.4f, %0.4f" % edge.start.position.to_a
puts "edge end = %0.4f, %0.4f, %0.4f" % edge.end.position.to_a
puts "edge start parent = " + edge.start.parent.to_s[12..-2]
puts "edge end parent = " + edge.end.parent.to_s[12..-2]
end
end
end #Tool
tb = UI::Toolbar.new('Sick Arc Inspector')
cmd = UI::Command.new("Sick Arc Inspector") { Sketchup.active_model.select_tool(InfoTool.new)}
cmd.menu_text = "Sick Arc Inspector"
cmd.tooltip = "Sick Arc Inspector"
cmd.status_bar_text = "Click on a sick entity"
tb.add_item cmd
tb.show
SKETCHUP_CONSOLE.show
nil
end
Sick Arc Tool.rb (2.4 KB)
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.