Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am new to the API and working through it.
I have the code below, but it determines the distance between the points picked on the cylindrical surface, not the actual centerline of the cylindrical feature. How do you drill down and get the center line (or center point) of the cylindrical surfaces that are selected? (Similar to how the "Measure" dialog box does it)
Do you need to change how the item is selected? Or can you manipulate the selection and find the center?
# Start of Code
import adsk.core, adsk.fusion, adsk.cam, traceback, math
def run(context😞
ui = None
try:
app = adsk.core.Application.get()
design = app.activeProduct
ui = app.userInterface
# ui.messageBox('Hey Phil')
rootComp = adsk.fusion.Component.cast(design.rootComponent)
ui.messageBox('Select two clynidrical faces')
selectedItem1 = ui.selectEntity("Select a Cylinder", "CylindricalFaces")
selectedItem1Value = selectedItem1.point
selectedItem2 = ui.selectEntity("Select another Cylinder", "CylindricalFaces")
selectedItem2Value = selectedItem2.point
lengthBetweenPoints = selectedItem1Value.distanceTo(selectedItem2Value)
unitsMgr = design.unitsManager
dispLengthBetweenPoints = unitsMgr.formatInternalValue(lengthBetweenPoints, unitsMgr.defaultLengthUnits, True)
ui.messageBox('Length is' +dispLengthBetweenPoints)
Solved! Go to Solution.