Here is the thing:
In your code, it is not clear what kind of sketch you are passing as a parameter.
THERE IS JUST ONE TYPE: adsk.funsion.Sketch. It is completely clear what kind of parameter i am passing and there is not even an alternative 😉
I understand the flow of your code but i am unable to adapt it to my purpose. I am very sorry. I will continue to try, but the situation is somewhat complicated.
Basically, i need to make a sketch in the currently active component (that may be root or some sub-component) and then select stuff successfully - a truly expert topic i have not mastered yet.
Meaning, the selection process must work with sketches and with sketches that are not sketches but are called sketches and also passed as adsk.fusion.Sketch while not being actual sketches. Especially i must be able to select sketch entities from root-sketches and also sketch entities that are not sketch entities (even if their type says so) that come from a sketch that is not a sketch despite being passed around as adsk.fusion.Sketch object representing a sketch that is not a sketch with entities that are not entities from an object that is not root.
In somewhat easier terms, i have no idea how to get the occurance of the activeComponent to pass it to createForAssemblyContext() in the context of the active component being some random component or root.
Or maybe even more compact: Is there a way to convert any adsk.fusion.Sketch that to an actual adsk.fusion.Sketch no matter where the original sketch comes from?
Edit: this seems to give me a sketch to work with. But i am unsure how generalized it is, since i am only referring to occuranceList.item(0). I do not understand the nuances of that aspect.
occurcanceList = root.occurrencesByComponent(design.activeComponent)
component: adsk.fusion.Component = root
occ = None
if occurcanceList.count != 0:
occ = occurcanceList.item(0)#itemByName(design.activeComponent.name)
component = occ.component
TargetSketch: adsk.fusion.Sketch = component.sketches.add(root.xYConstructionPlane)
TargetSketch.name = 'MinimumSurfaceSketch'
if occ is not None:
TargetSketch = TargetSketch.createForAssemblyContext(occ)
I can now use the sketch as if it was a sketch. Basically a one-liner as it should have been. *facepalm*
adsk.fusion.ThankYou.