Creating and Referencing Sweep features where pre-existing sweep features exist

Creating and Referencing Sweep features where pre-existing sweep features exist

Aaargh74
Explorer Explorer
330 Views
1 Reply
Message 1 of 2

Creating and Referencing Sweep features where pre-existing sweep features exist

Aaargh74
Explorer
Explorer

Hi All,

I'm having trouble running a script multiple times in the same design.

I am writing a script to add a sweep on a selected profile loop on an existing sketch.

The intent is to run the script multiple times on the same sketch, selecting different profiles each time to build up a body for machining 

The first time the script runs it creates the sweep features around the profile loop correctly.

The second time the script is run on a different profile loop it fails.

I reference the Sweep Features Collection in the script to apply trims etc. 

What is best practice?

1) Do I need to save the number of items already in the collection and apply an offset when referencing them for trims etc or is there a better method of returning the sweep features created when the script runs that considers other sweeps already in the design before the script is run.

2) apply attributes or save references to the features in the script.  

 

Regards

Paul.

 

 

 

0 Likes
331 Views
1 Reply
Reply (1)
Message 2 of 2

tykapl.breuil
Advocate
Advocate

Given your situation, I would advise creating an addin instead and simply storing on a global list the sweep features you create and moving your original script into the CommandCreatedEvent of a button you add to the Fusion360 interface. However, if you want this to still work after relaunching Fusion, what you could do is put an attribute on the features you create so you know which one they are. I would advise against using the indexes of the sweep features because they might change if you manipulate the timeline/delete features.

 

If that doesn't answer your question, please give us a sample code so your workflow is more clear.

0 Likes