How do I use the centroid as a vector?

MichaelPascoe
MichaelPascoe Member Posts: 2,959 PRO
edited September 2020 in FeatureScript
I found the centroid of my sketch with this:
var centroid = evApproximateCentroid(context, { //Finds the centroid of the selected face.
                    "entities" : definition.selectedFace
        });

The hint says it returns a vector, but when I try to use the variable "centroid" as a position in my sketch point, it says it's not a vector. and throws this error: Precondition of skPoint failed (value.position is undefined || is2dPoint(value.position))

Code for my sketch point:
var pt = skPoint(sketch, "point1", { "position" : centroid});   

Once the point is placed, how would I query the point so that I could use it in a loft?



RENDERCAD - Photorealistic product rendering.
CADSharp - Professional CAD + software consulting.

▚▞▚▞▚▞▚▞▚

Best Answers

Answers

  • MichaelPascoe
    MichaelPascoe Member Posts: 2,959 PRO
    I tried this:
    var centroid2d = worldToPlane(realPlane2, centroid);
    realPlane2 is the plane my sketch is on.

    I'm still failing to implement it correctly. It throws this: Call worldToPlane(Query (map), Vector (array)) does not match worldToPlane(Plane, ...)





    RENDERCAD - Photorealistic product rendering.
    CADSharp - Professional CAD + software consulting.

    ▚▞▚▞▚▞▚▞▚
  • MichaelPascoe
    MichaelPascoe Member Posts: 2,959 PRO

    RENDERCAD - Photorealistic product rendering.
    CADSharp - Professional CAD + software consulting.

    ▚▞▚▞▚▞▚▞▚