What's new

Scripting Project to Sketch

davex7637

Member
Hello all, I am new to the forum but I feel this is the best place to pick the brains of those well versed in Alibre and the scripting environment. My heavier programming background is mainly Matlab programming, and Python has become a new rather bumpy world. What I am creating is 3D curved parts that are lofted following 3D splines and 2D sketches at the front, middle, and end of the part. In order to do this, points are imported in 3D space following my script (simple one similar to the provided examples). After, I create planes between 3-points to have everything align for the final 2D sketches. The pain in my ass is projecting upwards of 10 data points to the sketch on the plane for each of the 3 sketches.

I, for the life of me, can find no mention of scripting the function of projecting to a sketch. AddPoint only works for 2D values, and since they are 3D points and the planes do not align with the cartesian planes I have no clue how to expedite the process. Any help is appreciated! Thank you.

1742611920356.png

an example of the points and plane generated for the sketch. The script I currently have creates the points, planes, and sketches.
 
Sketch.PointtoGlobal(U, V) "converts a point on the 2D sketch into a 3D point in the part coordinate system" and Sketch.GlobaltoPoint(X,Y,Z) "projects a 3D point in the part coordinate system into a point on the 2D sketch."
Since you already have the point in 3D from the 3D sketch you can just use GlobaltoPoint.

However if you are going from one part to another in an Assembly you will also need AssembledPart.PartPointtoAssemblyPoint(List) which "converts a point in the part coordinate system into a point in the assembly coordinate system" and AssembledPart.AssemblyPointtoPartPoint(List) which "converts a point in the assembly coordinate system into a point in the part coordinate system".

I'm not sure off hand how transferring a curve or a spline world be done like an actual project to sketch.
 
Sketch.PointtoGlobal(U, V) "converts a point on the 2D sketch into a 3D point in the part coordinate system" and Sketch.GlobaltoPoint(X,Y,Z) "projects a 3D point in the part coordinate system into a point on the 2D sketch."
Since you already have the point in 3D from the 3D sketch you can just use GlobaltoPoint.

However if you are going from one part to another in an Assembly you will also need AssembledPart.PartPointtoAssemblyPoint(List) which "converts a point in the part coordinate system into a point in the assembly coordinate system" and AssembledPart.AssemblyPointtoPartPoint(List) which "converts a point in the assembly coordinate system into a point in the part coordinate system".

I'm not sure off hand how transferring a curve or a spline world be done like an actual project to sketch.
That's awesome! I will try it out, thank you! I did notice that the point coordinates did change to their U,V values rather than initial cartesian values. Thanks for your help.
 
Back
Top