Cancel
Showing results for 
Search instead for 
Did you mean: 

Working with sketch coordinate system

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hello everyone!

 

Is it possible to programmatically create lines in sketch entering start and end points values relative to the internal sketch coordinate system? I tried to record a journal but it was of no use because points there are absolute. Can you please give an advice?

3 REPLIES

Re: Working with sketch coordinate system

Genius
Genius
I have never tried it but you can get the Orientation of the local coordinate system with "sketch.orientation" and the local origin with "sketch.origin".
Then you can create a line with "workpart.CurveCollection.CreateLine(Point3d, Point3d)" and add it to the sketch with "sketch.AddGeometry(DisplayableObject)"

Re: Working with sketch coordinate system

Creator
Creator

Is there any way possible to programatically distinguish and select the sketch from the part body?

Re: Working with sketch coordinate system

Siemens Phenom Siemens Phenom
Siemens Phenom

Mapping from the sketch coordinate system to the absolute coordinate system is pretty simple.

 

Suppose that

  • the sketch origin is at the point sketchOrigin
  • the x-axis of the sketch coordinate system is the vector sketchX
  • the y-axis of the sketch coordinate system is the vector sketchY

Then, if you have a point with coordinates (h,k) in the sketch coordinate system, its absolute coordinates are

 

sketchOrigin + h*sketchX + k*sketchY

 

Here, the "*" denotes scalar-vector multiplication, and the "+" is vector addition. 

 

There are functions in both SNAP and NX/Open to do this sort of mapping, too, but it's just as easy to do it from first prnciples.

山田
yamada