Having difficulty with FindUsingRay method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all I wrote a program that is supposed to return the intersection of a ray and a surface but I'm not having much luck with it so far. It should print out a 1 for the found_entities ObjectEnumerator if the ray going through a surface but I've only gotten zeros back from it. Even when I surrounded the origin with a sphere.
'defines base sketch, active application, active document and transient geometry before
'pulling anything from the active document
'Dim oSketch As PlanarSketch
'oSketch = _invApp.ActiveEditObject 'set the planar sketch as the active edit object
Dim part_doc As PartDocument ' get the active part document
part_doc = _invApp.ActiveDocument 'set part_doc as the active part document
Dim trans_geo As TransientGeometry 'get transient geometry from the application
trans_geo = _invApp.TransientGeometry 'set trans_geo as Transient Geometry object
'get the part component
Dim oDef As PartComponentDefinition
oDef = part_doc.ComponentDefinition
'define a neutral object to hold whats been picked
Dim oObject As Object
'select the surface to project to
oObject = _invApp.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick a surface")
Dim oSurface As Face 'define a face.
oSurface = oObject ' set oSurface as the selected surface.
Dim vect As UnitVector 'define a vector
vect = trans_geo.CreateUnitVector(1, 1, 1)
Dim point1 As Point
point1 = trans_geo.CreatePoint(0, 0, 0)
Dim dist As Double = 0
'Entities for sending Find using ray outputs
Dim found_entities As ObjectsEnumerator = _invApp.TransientObjects.CreateObjectCollection()
Dim locate As ObjectsEnumerator = _invApp.TransientObjects.CreateObjectCollection()
'Dim point2 As Point
oDef.FindUsingRay(point1, vect, 0.0001, found_entities, locate, True)
Debug.Print(found_entities.Count)