Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Another newbie question: I'm trying to get the intersection points between intersecting geometries in a sketch. I am trying to use SketchLine.intersections Method (line 59 in the attached code). It crashes on that line of code. Can someone explain what I am doing wrong. Thanks again.
Eric
#Author-Bunn
#Description-
increment = .1
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')
# Get sketch points
projCrv = sketch.project(prodBody)
sketchCurves = sketch.sketchCurves
BB = sketch.boundingBox
minBB = BB.minPoint
maxBB = BB.maxPoint
minBB = sketch.modelToSketchSpace(minBB)
minX = minBB.x
minY = minBB.y
minZ = minBB.z
maxBB = sketch.modelToSketchSpace(maxBB)
maxX = maxBB.x
maxY = maxBB.y
maxZ = maxBB.z
#Create Base Line on Sketch
lines = sketch.sketchCurves.sketchLines
line1 = lines.addByTwoPoints(adsk.core.Point3D.create(maxZ-increment , minY , 0), adsk.core.Point3D.create(maxZ-increment , maxY ,0))
intersections = line1.intersections(sketchCurves)
i= increment
while i <= maxZ:
retval = line1.intersectWithCurve()
i += increment
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.