Use TextCommands
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Those who are aware of the methods described below feel like they are not here.
I believe that it will bring great benefits to add-in developers and would like to share information.
Since Ver2.0.8335, it is possible to use text commands with API with "Application.executeTextCommand".
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-4DA98A57-C8E0-479E-B2FF-EB3C10BAE13F
The contents described from here are all about the TextCommandS(Txt).
I don't know C++, so it's written in python, but it should be available in C++.
Also, I can't speak English at all. If there is an inappropriate description, it would be helpful if someone could supplement it.
〇Display a list of TextCommands
As far as I know, I can hardly find any information about TextCommands.
Probably not a feature for the end user.
Therefore, I discovered it while trying various things. I had a hard time.
Here is the command to display all commands and a brief description.
TextCommands.List /hidden
However, this is not necessarily all commands. Because this is displayed.
TextCommands.LoadDll - [/unload] <FileName> Loads a DLL (that may contain new text commands!)
I can't figure out which DLL file is pointing to.
Also, although it is not compared in detail, it seems that the number of commands increases or decreases with each update.
The old version (Ver2_0_8176) is up here. You can understand by comparing them.
〇Execute the "executeTextCommand" method
I have answered several times using "Application.executeTextCommand" in the forum, but I would like to show you how to use it that seems to have merit.
PipeFeature Object is provided by API, but it is a typical one that cannot be instantiated.
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-6449ACAC-F731-4D10-8EC4-8477120B197F
As you can see, there are no methods like "add" or "create".
However, as you can see if you execute the following script, you can create PipeFeature.
#Fusion360API python script
#Author-kantoku
#Description-create PipeFeature sample
import adsk.core, adsk.fusion, traceback
_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)
def run(context):
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
# new doc
_app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
des :adsk.fusion.Design = _app.activeProduct
des.designType = adsk.fusion.DesignTypes.ParametricDesignType
root :adsk.fusion.Component = des.rootComponent
# create sketch
crv = initSktCircle(root)
# create pipe
initPipe(crv)
# create sketch
crv = initSktSpline(root)
# create pipe
initPipe(crv)
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def initSktSpline(comp :adsk.fusion.Component):
skt :adsk.fusion.Sketch = comp.sketches.add(comp.xYConstructionPlane)
poss = [[-1,2,5], [2,1,0], [0,-4,2]]
pnt3D = adsk.core.Point3D
objs = adsk.core.ObjectCollection.create()
[objs.add(pnt3D.create(x,y,z)) for (x,y,z) in poss]
crvs :adsk.fusion.SketchCurves = skt.sketchCurves
crv = crvs.sketchFittedSplines.add(objs)
return crv
def initSktCircle(comp :adsk.fusion.Component):
skt :adsk.fusion.Sketch = comp.sketches.add(comp.xYConstructionPlane)
pnt3D = adsk.core.Point3D
crvs :adsk.fusion.SketchCurves = skt.sketchCurves
crv = crvs.sketchCircles.addByCenterRadius(pnt3D.create(-5.0,-5,0), 4.0)
return crv
def initPipe(path):
sels :adsk.core.Selections = _ui.activeSelections
sels.clear()
sels.add(path)
txtCmds = [
u'Commands.Start PrimitivePipe', # show dialog
u'Commands.SetDouble SWEEP_POP_ALONG 1.0', # input distance
u'Commands.SetDouble SectionRadius 0.5', # input radius
u'NuCommands.CommitCmd' # execute command
]
for cmd in txtCmds:
_app.executeTextCommand(cmd)
sels.clear()