Message 1 of 3
Select Multiple Profiles from UI and add to ObjectCollection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello again,
I think I'm close, and massively miles away at the same time. I have successfully extruded one profile from UI; now I want to extrude multiple, based on user selection, add to collection, and iterate to extrude by different amounts each time, like steps.
Here's what I've got thus far, any help would be great:
import adsk.core, adsk.fusion, traceback def run(context): try: global app, ui app = adsk.core.Application.get() ui = app.userInterface design :adsk.fusion.Design = app.activeProduct rootComp :adsk.fusion.Component = design.rootComponent # Get extrude features extrudes = rootComp.features.extrudeFeatures # Asks for amount of Profiles (Amount) = ui.inputBox('Enter Profile Amount', 'Profile Amount', '12') # Create an object collection to use an input. profs = adsk.core.ObjectCollection.create() profs.Length = ('12') # Do I have to set array lenght in python?? # Asks for first Profile faceSel = ui.selectEntity('Select a profile', 'Profiles') if faceSel: face = adsk.fusion.Profiles.cast(faceSel.entity) #Need to add multiple profiles, specified by profile Amount #Psudo code: For x in profs, add profile entity # Get the extrusion Amount. (diam, cancelled) = ui.inputBox('Enter extrusion Amount', 'Extrusion Amount', '100.0 mm') if cancelled: return prof = faceSel.entity # Add all of the profiles to the collection. #for prof in faceSel: # profs.add(prof) # Create extrude _| # _| | #Psudocode for each profile in profs add extrusion amount plus x _| | | # _| | | | # From Extrude Samples: A simple way of creating typical extrusions (extrusion that goes from the profile plane the specified distance). # Define a distance extent of 5 cm distance = adsk.core.ValueInput.createByReal(5) extrude1 = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewBodyFeatureOperation) # Get the extrusion body body1 = extrude1.bodies.item(0) body1.name = "simple" # Get the state of the extrusion health = extrude1.healthState if health == adsk.fusion.FeatureHealthStates.WarningFeatureHealthState or health == adsk.fusion.FeatureHealthStates.ErrorFeatureHealthState: message = extrude1.errorOrWarningMessage # Get the state of timeline object timeline = design.timeline timelineObj = timeline.item(timeline.count - 1); health = timelineObj.healthState message = timelineObj.errorOrWarningMessage except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))