Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been learning and searching for days now and I will admit I have to be missing something and it could be basic. There are wonderful examples how to make a DXF file from an existing active model, but from the python code I am just not able to get the body and the wanted sketches. I can each sketch exported as its own dxf fine. I can see each sketch and its name, but when I go and project the sketches I want, I am only getting the body. Here is the code:
design : adsk.fusion.Design = app.activeProduct
rootComp = design.rootComponent
sketches = rootComp.sketches
folder = "W:\\SharedData\\Fusion_360\\DXF\\"
fullPath = os.path.join(folder, order)
i1 = 0
for sk in sketches:
sketch = sketches.item(i1)
# Get sketch health state
health = sketch.healthState
if health == adsk.fusion.FeatureHealthStates.ErrorFeatureHealthState or health == adsk.fusion.FeatureHealthStates.WarningFeatureHealthState:
ui.messageBox(sketch.errorOrWarningMessage)
if ("Pen_Line" in sketch.name or "Block" in sketch.name😞
sketch.saveAsDXF(fullPath + sketch.name + '.dxf')
i1 = i1 + 1
#=================WORKS GREAT TO HERE========================
#Creates a new sketch on the specified planar entity
master: adsk.fusion.Sketch = rootComp.sketches.add(rootComp.xYConstructionPlane)
targetBody: adsk.fusion.BRepBody = rootComp.bRepBodies[0]
#Projects the specified entity or entities onto
# the x-y plane of the sketch and returns the created sketch entity(s)
project_result = master.project(targetBody)
if project_result == False:
print('Failure in DXF processing')
sketch_names = []
sk_cnt = 0
for rtskcnt in rootComp.sketches:
ohmyname = rootComp.sketches.item(sk_cnt).name
sketch_names.append(rootComp.sketches.item(sk_cnt).name)
master.include(rootComp.sketches.item(sk_cnt))
sk_cnt = sk_cnt + 1
project_result = master.project(rootComp.sketches)
if project_result == False:
print('Failure in DXF processing')
app.log(str(sketch_names))
# write the merged file
folder = "W:\\SharedData\\Fusion_360\\DXF\\"
fullPath = os.path.join(folder, order)
master.saveAsDXF(fullPath + '.dxf')
msg = '!! DXF file has been written !!'
print(msg)
futil.log(msg)
I have also attempted projecting the ...item but I can't get anything to work. I DO get all the individual dxf files with the sketches and one for the body, I am so close hoping someone can see what I can't. Thank you in advance!!!
PS. Master is the new sketch made to contain all the sketches and body.
Solved! Go to Solution.