Ojascki
September 26, 2023, 4:22pm
1
Discrepancy between welded Curves and “valid” Curves
Consider a loop of edges with an additional singleton edge sharing one of the loops vertices (fig a).
When “Welding” the set of edges (via the Ruby API), the loop of edges is identified as a single polyline and become a Sketchup::Curve. I consider this behaviour “correct”.
The singleton edge also becomes a Sketchup::Curve. I consider this behaviour “incorrect” (but not egregious). (fig b)
The set of edges & curves is reselected, then validated using Sketchup’s internal validation function (Windows > Model Info > Statistics > Fix Problems). The “loop curve” is identified as have “bad connectivity”. I presume this is because the Curve terminus vertices coincide with each other and a vertex of another Object (?). I consider this behaviour “incorrect” as the polyline is not violated at any “mid-vertex”.
The result after validation is that the loop curve is split into disassociated edges and the Curve object is lost.
I am currently writing a Ruby extension that is reliant on identifying loops of this nature as valid polylines. I can “re-welding” all edges immediately before processing to avoid Sketchup’s validate check but obviously it adds unnecessary processing time. More importantly, any generated curves of this nature will be “broken” when validation runs. Subverting the user’s expectations.
Is the above behaviour is as intended? if so, what propose does it serve? Is there any work-arounds or a way to flag the curve as valid before validation occurs?
Thanks in advance!
Code used to investigate the issue:-
model = Sketchup.active_model
edges = model.selection.grep(Sketchup::Edge)
puts "num_of_SU_Edges: " + edges.size.to_s
model.active_entities.weld( edges )
curve_edges , single_edges = edges.partition{ |edge| edge.curve }
curves = curve_edges.group_by{ |edge| edge.curve }
puts "num_of_SU_Edges (singles): " + single_edges.size.to_s
puts "num_of_SU_Edges (in curves): " + curve_edges.size.to_s
puts "num_of_SU_Curves: " + curves.size.to_s
puts "SU_Curves:-"
curves.each{ |curve|
hash = { OBJ: curve[0].inspect, ID: curve[0].entityID.to_s, num_of_Edges: curve[0].edges.size }
puts hash
}
Please report bugs in the official API issue tracker at:
This may be already logged, see:
opened 07:41PM - 04 Oct 19 UTC
bug
Ruby API
SketchUp
logged
corruption
SketchUp 2017 Make
Windows 10
I'm creating 2D shapes on the ground plane wit… h welded (curves) edges that connect together at 1 vertex.
Under certain conditions, the Validity Check results in a bad model.
The problem initial was discovered by creating shapes via ruby API but most of my test scenarios include shapes created via the toolset (manually). Because the issue initially involved Curve objects, I also tested shapes having the ArcCurve subclass.
All my tests involve 2 shapes that are always connected by a single vertex. Anytime I refer to a Curve shape, I'm talking about a closed-loop shape whose edges are Curve objects. Polyline references are a single edge Curve object. The combination of shapes in my test scenarios are not exhaustive but based on my test results, I've concluded the following:
1. Joining two Arc objects results in no issues at all.
2. Joining two Polygon objects always results in a bad model.
3. Joining two Circle objects always results in a bad model.
4. Joining two Curve objects results in a bad model depending on whether or not the first vertex was used to connect the shape. If neither of the shapes are connected by their first vertex then no problems are found.
5. Joining two Polyline objects results in no issues.
When testing a combination of shapes (e.g. an Arc with a Circle), I concluded:
6. A Polygon connected to any Curve based shape (Arc, Circle, Curve) results in a bad model.
7. A Circle connected to any Curve based shape (Arc, Circle, Curve) results in a bad model.
8. Anytime a Curve, connected by it's first vertex, to any other Curve based shape will result in a bad model.
The results of Polygon and Circle objects seem identical which makes sense since I believe they are both based on the same ArcCurve class.
I've attached the following files.
1. An Excel file containing the test scenarios. Each test scenario shows the name of the shape and which vertex of the shape was used in the single point connection. Also the Validity Check results are included.
2. The SketchUp file with the shapes referenced in the Excel file. Each of the shapes are in their own group. To demonstrate the issue, you'll need to explode both shapes in the test so they reside in the same group and then run the validity checker.
3. The screen shots below.
For example, here are some screen shots:
First the Excel file test scenarios:
![image](https://user-images.githubusercontent.com/35354237/66233249-bd33fc00-e69f-11e9-8dbd-a411403da320.png)
Sample of scenario A01, showing Polygon1's **3**rd vertex (highlighted) connected to Arc2. This is reflected in row 5 of the Excel file.
![image](https://user-images.githubusercontent.com/35354237/66233357-ff5d3d80-e69f-11e9-95f9-c880c58a5596.png)
This screen shot shows the same Polygon1 and Arc2 groups highlighted. When these are exploded and the model validated, it results in a bad model.
![image](https://user-images.githubusercontent.com/35354237/66233464-48ad8d00-e6a0-11e9-82af-4154eb688b99.png)
![image](https://user-images.githubusercontent.com/35354237/66233473-53682200-e6a0-11e9-91aa-a3f126e64617.png)
Test scenario F01 objects were created from the ruby code below. Notice that the two objects (when exploded) will result in a connection at point [3,3,0] which is the first vertex for the Curve loop. This results in a bad model.
```ruby
points_a = []
points_a.push(Geom::Point3d.new(3,3,0))
points_a.push(Geom::Point3d.new(0,0,0))
points_a.push(Geom::Point3d.new(6,0,0))
points_a.push(Geom::Point3d.new(3,3,0))
points_b = []
points_b.push(Geom::Point3d.new(3,3,0))
points_b.push(Geom::Point3d.new(3,6,0))
model = Sketchup.active_model
group_test_curves_scenario = model.entities.add_group
group_test_curves_scenario.name = "scenario_F_01"
group_a = group_test_curves_scenario.entities.add_group
group_a.name = "Curve1"
group_a.entities.add_curve(points_a)
group_b = group_test_curves_scenario.entities.add_group
group_b.name = "Polyline2"
group_b.entities.add_curve(points_b)
```
If the points in the points_a array are replaced with these lines below, which rotate the points such that the first vertex is no longer the point of connection, then there are no issues when the groups are exploded. This was the code used to create Curve1 in scenario F03.
```ruby
points_a.push(Geom::Point3d.new(0,0,0))
points_a.push(Geom::Point3d.new(6,0,0))
points_a.push(Geom::Point3d.new(3,3,0))
points_a.push(Geom::Point3d.new(0,0,0))
```
That concludes my testing. Let me know if there are any questions or if anything needs better/more clarification.
Thanks
[Test Case Model.zip](https://github.com/SketchUp/api-issue-tracker/files/3692023/Test.Case.Model.zip)
Ojascki
September 26, 2023, 9:44pm
3
Thanks Dan, I was not aware of the tracker.
Seems SU are in no rush to fix this …
“The welding hand giveth and the validating hand taketh away”
1 Like
system
Closed
March 30, 2024, 4:22pm
4
This topic was automatically closed after 186 days. New replies are no longer allowed.