Are there documented rules for creating/joining geometry via ruby script?

SketchUp is detecting issues in the geometry I create via ruby api. The issues are shown in the Validity Check window. I would like to know what the “rules” are for creating and joining various geometry (eg, curves (all types arcs, circles, ngons, etc), faces, lines, etc.) so I can avoid the validity check issues.

My current issue is with curves via the add_curve() method.

For example, creating two curves shaped as triangles each in there own group. If the groups are connected by a single vertex and then exploded, SketchUp generates a validity check like this:

Results of Validity Check.

The connectivity for CCurve (3879) is bad - fixed

When you fix the problem, Sketchup chooses one of the curves as the “victim” and destroys the curve, leaving the edges of course.

From experimenting, I’ve theorized the following 2 rules for curves:

  1. A vertex can join many edges each of which belong to a different curve (no loops).
  2. A vertex can join 2 edges from the same curve (in a loop) but then cannot have any other edge that participates in a curve.

The problem is that I’m not sure these rules are correct or even complete.

Instead of having to experiment in order to detect what SketchUp is doing, I’d like to just read what the rules are for creating geometry and follow them.

Is there any documentation that explains these types of rules that “should” be followed in order to avoid validity checks? I don’t want to ignore the validity checks, I want to avoid them.

BTW: I’m currently using SketchUp 2017 Make

Thanks!

look up ‘bowtie’ issues, as it sounds like your description of the shape…

an image and code would take away the guesswork…

john

1 Like

Here’s some code showing the issue. There’s one triangle curve and another curve with just one edge, each in separate groups.

	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 = "test_curves"

	group_a = group_test_curves_scenario.entities.add_group
	group_a.name = "group_a"
	group_a.entities.add_curve(points_a)


	group_b = group_test_curves_scenario.entities.add_group
	group_b.name = "group_b"
	group_b.entities.add_curve(points_b)

After running the code, explode group_a and group_b. Then run a validity check and you get a message like:

Results of Validity Check.

The connectivity for CCurve (3950) is bad - fixed

My original post description was definitely a bow tie. I used this code, which is not a bow tie, to show that it’s not always just loops touching each other that cause problems. Even putting two ngon’s in separate groups, connected by a vertex, then exploded cause a similar validity issue. Basically they are the same issue dealing with curves.

However, my main question isn’t really about getting around this specific issue, this was just an example to highlight the need for documentation explaining the rules. I’d like to know what the rules are when creating geometry, like what scenarios to avoid so I’m not getting the validity issues. I don’t want to be guessing at the rules and constantly refactoring my code when I run into another issue that I wasn’t aware of. Does such documentation exist?

Here’s a picture of the triangle and line (each originally separate curves) after exploding the groups and running the validity check…

Unfortunately, no.

The YARD documentation generator allows for these kind of tutorial files to be added. But only a few have been written so far.

The API dictionary of classes and methods are terse and not meant to be a teaching document. (Ie, it’s an API reference, not a programmer’s handbook.)

There is talk of working on the files repo. It’d be hosted on GitHub in the SketchUp Team’s repositories.

It came up recently in this thread …

… which prompted this specific topic to be opened …

:bulb:

Now that is not to say that some have created SketchUp developer tutorials …

There is a list of tutorials in my reference lists …

The IDEAS list have examples of what some of the “handbook” articles might be.

Thanks Dan, I’ll have a look at the resources you provided. I’d be happy with just a documented list of the checks that the validity checker is making (and what they mean in layman terms). Knowing that should be enough to avoid the validity pitfalls without the need for any tutorial or programmer’s handbook. Although, having those would be GREAT!

Please open a documentation request for this in the API issue tracker.