Intersection between plane and suface

Intersection between plane and suface

ione_ianniruberto
Contributor Contributor
563 Views
2 Replies
Message 1 of 3

Intersection between plane and suface

ione_ianniruberto
Contributor
Contributor

Hi, 

I need to find three points that are the result of the intersection between the plane and the complex geometry in the figure. 

I tried to use intersectionwithSurface, as a result I obtain a Nurbs3DCurve and then I get the pointatparameter 0.0 but the resulting coordinates are not correct. 

Those are the lines of my code:

punti_intersezione1 = piano.intersectWithSurface(loftsurface)
punti_intersezione1 = punti_intersezione1.asArray()
punto1 = punti_intersezione1[0].evaluator
(returnvalue1, punt1) = punto1.getPointAtParameter(0.0)

I don't know il the coordinate that I get are in the reference system of the plane or I'm doing something wrong.

Does someone know how to solve this?
Thanks so much 

Ione

Screenshot 2023-11-06 164103.png

0 Likes
Accepted solutions (1)
564 Views
2 Replies
Replies (2)
Message 2 of 3

Jorge_Jaramillo
Collaborator
Collaborator
Accepted solution

Hi,

 

I believe you problem could be in this line:

(returnvalue1punt1= punto1.getPointAtParameter(0.0)

You might need to check if 0.0 is between the parameter range of the curve.  For this you can use punto1.

getParameterExtents() method.

 

I adapted you coded to some design I made and I drew three points on a XYplane sketch like so:

    piano: adsk.core.Plane = root.constructionPlanes[0].geometry
    loftsurface: adsk.core.NurbsSurface = root.bRepBodies[0].faces[0].geometry

    punti_intersezione1 = piano.intersectWithSurface(loftsurface)
    punti_intersezione1 = punti_intersezione1.asArray()
    punto1: adsk.core.CurveEvaluator3D = punti_intersezione1[0].evaluator
    (returnvalue1, punt1) = punto1.getPointAtParameter(0.0)

    (_, par_min, par_max) = punto1.getParameterExtents()
    app.log(f'{punto1.getParameterExtents()=}')

    # to draw points on sketch over xyPlane
    sk: adsk.fusion.Sketch = root.sketches.add(root.xYConstructionPlane)
    for par in [par_min + (par_max - par_min) * factor for factor in [0, .33, .66]]:
        (_, p) = punto1.getPointAtParameter(par)
        sk.sketchPoints.add(p)
        app.log(f'{par=} {p.asArray()=}')

 

You can see I used factors 0, .33 and 0.66 to get 3 different points.

Since the punto1 refers to a close curve, the lower bound and upper bound of the parameter range made the same point with the getPointAtParameter() method (as if you use factors 0.0, 0.5 and 1.0).

You can use any factor combination, every one in the range 0.0 to 1.0.

 

The result I get is 3 points in the intersection between the plane and the body's surface.

I hope this can help you out.

 

Regards,

Jorge Jaramillo

Software Engineer

 

 

Message 3 of 3

ione_ianniruberto
Contributor
Contributor
Thanks so much! This is very clear
0 Likes