Hi i am trying to select a linear dimension using a command input but without success. I am using the filter
"SketchConstraints" for the selection filter but i can only choose geometric constraints but not dimensional constraints.
according to the documentation
SketchConstraints = Selects sketch geometric and dimensions constraints.
but doesent seem to support dimensions constraints.
hi.p.hemmege
'SketchConstraints' certainly seems to be unusable.
I was interested in 'Selection Filters', so I made the following code.
import adsk.core, adsk.fusion, traceback def InitFilterList(): return [ 'Bodies', 'SolidBodies', 'SurfaceBodies', 'MeshBodies', 'Faces', 'SolidFaces', 'SurfaceFaces', 'PlanarFaces', 'CylindricalFaces', 'ConicalFaces', 'SphericalFaces', 'ToroidalFaces', 'SplineFaces', 'Edges', 'LinearEdges', 'CircularEdges', 'EllipticalEdges', 'TangentEdges', 'NonTangentEdges', 'Vertices', 'RootComponents', 'Occurrences', 'Sketches', 'SketchConstraints', 'Profiles', 'Texts', 'SketchCurves', 'SketchLines', 'SketchCircles', 'SketchPoints', 'ConstructionPoints', 'ConstructionLines', 'ConstructionPlanes', 'Features', 'Canvases', 'Decals', 'JointOrigins', 'Joints' ] def run(context): app = adsk.core.Application.get() ui = app.userInterface filterLst = InitFilterList() print('') print('** Fusion360 ver:{} **'.format(app.version)) for filter in filterLst: try: ui.selectEntity('Select / ESC-Cancel', filter) print('{}'.format(filter).ljust(20,' ')+':ok') except RuntimeError: print('{}'.format(filter).ljust(20,' ')+':RuntimeError') except: pass
The results are as follows.
** Fusion360 ver:2.0.4126 ** Bodies :ok SolidBodies :ok SurfaceBodies :ok MeshBodies :ok Faces :ok SolidFaces :ok SurfaceFaces :ok PlanarFaces :ok CylindricalFaces :ok ConicalFaces :ok SphericalFaces :RuntimeError ToroidalFaces :ok SplineFaces :ok Edges :ok LinearEdges :ok CircularEdges :ok EllipticalEdges :ok TangentEdges :ok NonTangentEdges :ok Vertices :ok RootComponents :ok Occurrences :ok Sketches :ok SketchConstraints :ok Profiles :ok Texts :ok SketchCurves :ok SketchLines :ok SketchCircles :ok SketchPoints :ok ConstructionPoints :ok ConstructionLines :ok ConstructionPlanes :ok Features :ok Canvases :ok Decals :ok JointOrigins :ok Joints :ok
'SphericalFaces' will not function, it will result in an error.
Even if it is described in the Japanese forum, it is hardly to be opponent.
ok but have you tried the SketchConstraints ? and were you able to selecet the dimensional constraints with this?
Although it will not be an error, I also 'SketchConstraints' will not succeed.
Sorry for taking out old topics.
It has not been improved yet due to the bug of Selection Filters-SketchConstraints here. (Fusion360 Ver2.0.7402)
http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-03033DE6-AD8E-46B3-B4E6-DADA8D389E4E
Recently, I came up with a way to get around this.
I learned that using the Command.preSelect Event, you can get the element under the mouse cursor.
You can check the type and operate the selection.
I made a sample here.
https://github.com/kantoku-code/Fusion360-SelectFilter_T_Sample
I can't give detailed explanations in English, so if you are interested, please take a look.
CATIA macros have a similar selection function, and filters can use object names.
Bump
Although Fusion Help | Selection Filters | Autodesk states "SketchConstraints Selects sketch geometric and dimensions constraints.", when this filter is used, sketch dimensions are ignored. No other filter appears to work. With no filter set, as when using Fusion Help | CommandInputs.addSelectionInput Method | Autodesk , sketch dimensions can be selected and their objectType tested afterward, but this is an awkward solution and doesn't work with Fusion Help | UserInterface.selectEntity Method | Autodesk.
import adsk.core, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
while True:
try:
sel = ui.selectEntity("Select a sketch dimension", "SketchConstraints")
ui.messageBox(f"{sel.entity.objectType = }")
except:
return
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Thank you
Can't find what you're looking for? Ask the community or share your knowledge.