User select sketch point

User select sketch point

oyvindTMNSU
Advocate Advocate
446 Views
1 Reply
Message 1 of 2

User select sketch point

oyvindTMNSU
Advocate
Advocate

Can someone explain why I need the "pnt=" line in this code to display the point coordinates in a message box? 
And what's the thought behind the cast in that line. And why (pnrEntity.entity) after cast? 
It this something that I should fint in the documentation? In that case, where?

 

@BrianEkins maybe you have a good answer?

 

 

app = ask.core.Application.get()

ui = app.userInterface

pntEntity = ui.selectEntity('Select a sketch point', 'SketchPoints')

pnt = adsk.fusion.SketchPoint.cast(pntEntity.entity)

ui.messageBox('x:{0},y:{1},z:{2}'.format(pnt.geometry.x,pnt.geometry.y,pnt.geometry.z))

0 Likes
447 Views
1 Reply
  • API
Reply (1)
Message 2 of 2

JeromeBriot
Mentor
Mentor

Hello,

 

You can simply write:

pntEntity = ui.selectEntity('Select a sketch point', 'SketchPoints')

ui.messageBox('x:{0},y:{1},z:{2}'.format(pntEntity.entity.geometry.x, pntEntity.entity.geometry.y, pntEntity.entity.geometry.z))

But it decreases the code readability and it  breaks the "Maximum Line Length" convention when programming in Python.

 

For you question about the cast method: