Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Please refer to the code and screenshots below. I am doing the following:
- Creating a sketch on the YZPlane
- Projecting a body's outline on to the sketch.
- Pulling the sketch bounding box coordinates.
- Trying to plot a point at minPoint.
- The point is going to the maxPoint coordinates which is backwards from what I expected.
Can anyone explain this to me?
Thanks,
Eric
#Author-Bunn
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
radius1 = 2
radius2 = 0.156
#get the application
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
# #get the root component
# rootComp = design.rootComponent
#Cast the root component (casting versus setting will get access to more intellisense)
rootComp = adsk.fusion.Component.cast(design.rootComponent)
#create a new sketch on the xy plane
sketches = rootComp.sketches
Plane = rootComp.yZConstructionPlane
sketch = sketches.add(Plane)
sketch.name = 'YZ Plane'
#get the id of the cushion body
prodBody = adsk.core.ObjectCollection.create()
prodBody = rootComp.bRepBodies.itemByName('Pump')
# #Create Base Line on Sketch
# lines = sketch.sketchCurves.sketchLines
# line1 = lines.addByTwoPoints(adsk.core.Point3D.create(maxY , minZ , 0), adsk.core.Point3D.create(minY , minZ ,0))
# Get sketch points
sketch.project(prodBody)
BB = sketch.boundingBox
minBB = BB.minPoint
maxBB = BB.maxPoint
minX = minBB.x
minY = minBB.y
minZ = minBB.z
maxX = maxBB.x
maxY = maxBB.y
maxZ = maxBB.z
sketchPoints = sketch.sketchPoints
# Create sketch point
point1 = adsk.core.Point3D.create(minX, minY, 0)
sketchPoint1 = sketchPoints.add(point1)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.