[C API] How get the polygon curve data instead of getting the arc data

Dear experts,

I created a polygon without the face in the SketchUp application. But I don’t know how get the polygon curve data. Instead, I get a SUArcCurveRef from the model by the following API.

SUModelGetEntities(m_model, &entities);
size_t curveNum = 0;
SUEntitiesGetNumCurves(entities, &curveNum);
if (curveNum > 0)
        std::vector<SUCurveRef> curves(curveNum);
        SUEntitiesGetCurves(entities, curveNum, &curves[0], &curveNum);
        SUArcCurveRef arc = SUArcCurveFromCurve(curves[0]);

polygon.skp (178.4 KB)

Be more specific please. You have gotten a list of the Curves and accessed the first in the list.
You used that (gotten via index into the list) in a casting operation to get at the ArcCurve reference.
To get it’s underlying Curve data assign a reference to the same curve from the list, ie …

SUCurveRef curve = curves[0];

From that you can access the number and list of edges as explained …

In the C++ core and the Ruby OOP API, an ArcCurve is a subclass of the Curve class, which is Drawingelement subclass, which is a Entity subclass. Each subclass inheriting and passing down the functions of it’s superclass(es). But in C, you need to use type casting to access the functions of superclasses.

You may need to release the reference(s) to these objects when you’re done with them. (Each has is own release function.)

Your way works to get the polygon curve data by getting edges from SUCurveRef. If so, for the following arc curve, I also can get the edge list from SUCurveRef. It means that I can’t differentiate the real arc from the polygon by the C API. Then what is SUArcCurveRef designed for?

arc.skp (119.6 KB)

It may help you to also examine the classes of the Ruby API, as it more closely resembles the OOP C++ core of the SketchUp model.

With regard to the SUArcCurveRef (Sketchup::ArcCurve) class objects, … they will expose the center point, start and end angles, radius, as well as other properties that basic curves do not have … (basic curves can be non-circular, … ie, bezier curves, freehand curves, sine curves, etc. etc.)

The SketchUp APIs do not actually have polygon or circle objects as low level class objects. Instead they are just a closed set of equal length edges that are grouped into an ArcCurve object. (Their start and end vertices will be the same 3D point. The difference between the start and end angles should be 360 degrees.)


The Ruby API has a boolean Sketchup::Curve#is_polygon? method, but the C API does not have a complimentary function.

The C API has a SUArcCurveGetIsFullCircle function, but the Ruby API does not have a complimentary method.

I see you’ve opened an API issue last February …

@DanRathbun Thank you for your detailed comments.

1 Like

Yea, it’s on our list to backfill that property to the C API.