addDistanceDimension between organ and SketchPoint

addDistanceDimension between organ and SketchPoint

StephenCim-001
Advocate Advocate
994 Views
4 Replies
Message 1 of 5

addDistanceDimension between organ and SketchPoint

StephenCim-001
Advocate
Advocate

Hi All

 

I wanted to add a DistanceDimension between the origin (0,0,0) and a SketchPoint , but I could not get it to work. 

In the end I had to add a Sketch point on the origin and then I could add the distanceDimension between the 2 sketch points..., It works and I can drive the point from my user prams. 

Here is the code I'm using:

 

Origin = adsk.core.Point3D.create(0, 0, 0)

dims = sketch.sketchDimensions

sketchPoints = sketch.sketchPoints

point = adsk.core.Point3D.create(0, -(UserStoneFinalHeight.value) , 0)

SketchPointOrigin = sketchPoints.add(Origin)

sketchPoint = sketchPoints.add(point)

stoneDim = dims.addDistanceDimension(sketchPoint, SketchPointOrigin, 0 , adsk.core.Point3D.create(3,-3,0))

stoneDim.parameter.expression = 'StoneFinalHeight'

 

 

How do I should I declare the Origin in the addDistanceDim... statement, I tried Origin and adsk.core.Point3D.create(0, 0, 0)

 

Cheers, Stephen

0 Likes
Accepted solutions (1)
995 Views
4 Replies
Replies (4)
Message 2 of 5

p.seem
Advocate
Advocate

Stephen,

 

The origin isn't itself a sketch object, but you could probably project it in using the sketch.Project method.  But then you've got the added complexity of working out which coordinate system you care about, and finding that particular origin point to project.  But that all just seems like a more cumbersome version of your own "adsk.core.Point3D.create(0, 0, 0)" 

 

So if you'll forgive a stupid questions, what's wrong with your current method?

 

 

0 Likes
Message 3 of 5

StephenCim-001
Advocate
Advocate

I guess there is nothing wrong with it, I just thought since I could select the origin using the GUI I could do it in API 🙂

 

Cheers, Stephen

0 Likes
Message 4 of 5

BrianEkins
Mentor
Mentor
Accepted solution

When a new sketch is created,  Fusion automatically projects the origin point into the sketch. You can access the created sketch point using the origin originPoint property on the Sketch object. 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 5

StephenCim-001
Advocate
Advocate

Thanks Brian

 

That worked 🙂

0 Likes