- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi forumlanders,
there is something I do not understand ! (Just to learn something more)
In the first picture I used the user interface and created an ellipse on a sketch. Then with Sketch offset I created a second ellipse on the same sketch. When I tested the number of curves I found 4 curves.
These are the types of sketchCurves: the first three are sketchEllipse, sketchLine, sketchLine, the last is a sketchFilletSpline (I aspected an ellipse !!!)
In the second example (always created with the user interface) I have two sketch:
In the first I created an ellipse. I created a new sketch and copy this ellipse with ctrl-c / ctrl-v in the second sketch. Then I used Sketch offset to expand the second ellipse. I tested the type of curves here it what I found:
In the first sketch: SketchEllipse, SketchLine, SketchLine (all right)
In the second sketch: SketchEllipse, SketchEllipse (????)
Is it correct ????? I loose the axes of the ellipses and there is no more the SketchFilletSpline
Here is the script I used to test the curves type:
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
for s in design.rootComponent.sketches:
for e in s.sketchCurves:
tipo = e.objectType
ui.messageBox("Sketch: " + str(s.name)+" -- Curve type: "+str(tipo))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
I wrote a script in which I duplicated an ellipse with the scketch.offset method and I found the behavior of the first example. When I try to delete the curves, I cannot delete alle the curves. Almost an half of the curves !
What am I doing wrong ?
Here is the code
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
# new document
app = adsk.core.Application.get()
ui = app.userInterface
app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
design = adsk.fusion.Design.cast(app.activeProduct)
design.designType = adsk.fusion.DesignTypes.DirectDesignType
# Get the root component of the active design.
rootComp = design.rootComponent
# START - create ellipse on sketch 1 -----------------------------------
# Create sketch1 on the xz plane.
sketch1 = rootComp.sketches.add(rootComp.xZConstructionPlane)
# create collection of ellipses
ellipses1 = sketch1.sketchCurves.sketchEllipses
centerPoint = adsk.core.Point3D.create(0, 0, 0)
majorAxisPoint = adsk.core.Point3D.create(10, 0, 0)
minorpoint = adsk.core.Point3D.create(0, 5, 0)
# draw an ellipse
ellipse1 = ellipses1.add(centerPoint, majorAxisPoint, minorpoint)
# END - create ellipse on sketch 1 -----------------------------------
# create a collection of object and add ellipse1
ellipseCol = adsk.core.ObjectCollection.create()
ellipseCol.add(ellipse1)
# add ellipses (???) to sketch1
for i in range(1,7):
offset = 1*i
# Create the offset.
x = minorpoint.x + 2
y = minorpoint.y
dirPoint = adsk.core.Point3D.create(x, y, 0)
# create a new ellipse with offset
# !!!!!!!!!!!--------(but is a SketchFittedSpline)------!!!!!!
sketch1.offset(ellipseCol, dirPoint, offset)
ui.messageBox("Number of curves on sketch: "+str(sketch1.sketchCurves.count))
i=0
for e in sketch1.sketchCurves:
e.deleteMe()
i=i+1
ui.messageBox("Number of curves deleted: "+str(i))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))I have attached the simple sketchs if you want to test the code.
Thanks
Dino
Solved! Go to Solution.