Hello,
on the surface of a rotated body I would like to place a working point, which is defined by an radial axis and the faces of the body – does not sound that tricky, but its driving me nuts right now.
My approach was the following: I have the rotated body (given by the user) and a radial workaxis, which cuts through the surface. The Face which is cut can be a cylindrical face or a conus. I find the actual face using the FindUsingVector Method
Btw, I am using C#, but VB answers are highly appreciated as well 😉
ObjectsEnumerator fndObj;
object locPnts;
double rayRad = 0.01;
SelectionFilterEnum[] objtypes = new SelectionFilterEnum[1];
objtypes[0] = SelectionFilterEnum.kPartFaceFilter;
fndObj = oMMCompDef.FindUsingVector(wPoint2.Point, oWax1.Line.Direction, ref objtypes, true, rayRad, true, out locPnts);
Face fc = null;
foreach (object obj in fndObj)
{
fc = (Face) obj;
log.logMsg("out: " + fc.Vertices.Count + " " + fc.Type.ToString() + " " + fc.SurfaceType.ToString());
// log output: 18.09.2013 16:29:29 - out: 2 kFaceObject kCylinderSurface
}
WorkPoint wPoint3 = oMMCompDef.WorkPoints.AddByCurveAndEntity(oWax1, oWPlane4); // fine
WorkPoint wPoint4 = oMMCompDef.WorkPoints.AddByCurveAndEntity(oWax1, fc, wPoint3, false); // fails
From my understanding, locPnts already contains the intersection point, but I would like to have a Workingpoint with complete references. Therefore I use the AddByCurveAndEntity method, which is not happy with my parameters (Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) for workpoint wPoint4 . The generation Workpoint wPoint3 works great, but with the cylindrical face “fc” it fails. The documentation says, when the “curve” is a line, then any kind of face is allowed – what am I doing wrong?
Thank you for your help
Kai
Hi Kai,
I can't tell you anything based on that incomplete code sample... it seems to me that you are providing a WorkAxis as input parameter to AddByCurveAndEntity, which is not a supported type. Please provide the complete code sample along with a test part if you need any further help on that topic.
Thank you,
Philippe.
Hi Philippe,
Thank you for your answer. Sorry for the delayed feedback, but good news – I think I got it. Yes, you were right, I was providing a work axis to AddByCurveAndEntity, but that was not the issue. The issue was the workpoint wPoint3. I have to refer to its “geometry” wPoint3.Point - Here is the full method, which finally worked for me:
public void MMplaceNozzles(Inventor.PartDocument invPartDoc, Inventor.Application invApp) { try { oTG = invApp.TransientGeometry; oMMCompDef = invPartDoc.ComponentDefinition; WorkPlane oWPlane1 = oMMCompDef.WorkPlanes.AddByPlaneAndOffset(oMMCompDef.WorkPlanes["XY Plane"], 600, false); Inventor.Point ip2 = oTG.CreatePoint(0, 0, 600); WorkPoint wPoint2 = oMMCompDef.WorkPoints.AddFixed(ip2, false); WorkAxis oWax1 = oMMCompDef.WorkAxes.AddByTwoPlanes(oWPlane1, oMMCompDef.WorkPlanes["XZ Plane"]); WorkPlane oWPlane4 = oMMCompDef.WorkPlanes.AddByPlaneAndOffset(oMMCompDef.WorkPlanes["YZ Plane"], 1000, false); ObjectsEnumerator fndObj; object locPnts; double rayRad = 0.01; SelectionFilterEnum[] objtypes = new SelectionFilterEnum[1]; objtypes[0] = SelectionFilterEnum.kPartFaceFilter; fndObj = oMMCompDef.FindUsingVector(wPoint2.Point, oWax1.Line.Direction, ref objtypes, true, rayRad, true, out locPnts); Face fc = null; foreach (object obj in fndObj) { fc = (Face)obj; } WorkPoint wPoint3 = oMMCompDef.WorkPoints.AddByCurveAndEntity(oWax1, oWPlane4); // fine WorkPoint wPoint4 = oMMCompDef.WorkPoints.AddByCurveAndEntity(oWax1, fc, wPoint3.Point); // wPoint3.Point works fine } catch (Exception ex) { // log me } }
Thank you for your support!
Kai
Can't find what you're looking for? Ask the community or share your knowledge.