Hi Harsimran,
I am Ashok at Alibre. I looked at the VB code you posted and thought I would share my observations:
- Going by the variable names you have used, it appears that you have made some incorrect corelations with the object they actually represent. The assumption on your part maybe due to your familiarity with another CAD product's automation API. For instance you have named the variable storing the AutomationHook object as "swApp". Actually, the AutomationHook is just the entry point to Alibre's API and it is really not equivalent to the "Application" object you seem to have in mind. Actually, the IADRoot that you get from AutomationHook is more like the "App" object. And, every IADSession object enumerated by the IADSessions collection in IADRoot is more like the "Document" object.
Also, it appears you are trying to access a skech using the the "Root" property of and IADPartFeature. This gives you the same old IADRoot mentioned above, not an IADSketch. To get the feature's sketch, you would need to first get the correct feature interface like IADExtrusionFeature and then look up its "Sketch" property.
- Going back to IADSession interface, your program can get hold of this interface for an already opened part (or assembly) by iterating over all the IADSession objects got from IADRoot and then using the "Name" property as a way to identify the IADSession of interest to you. Alternatively, you could have used the "OpenFile" method on IADRoot to open an existing Alibre part file on disk; this method will open the part and return you its IADSession interface. After confirming that the session is actually a "part" (by checking the "SessionType" property on IADSession), you can assign the IADSession to a variable declared as IADPartSession.
- You can then drill down the part to obtain the sketch object(IADSketch) you are interested in -- one way is via the "Sketches" property in IADPartSession.
- You can continue drilling down a IADSketch to obtain its sketch figures collection from IADSketch interface. A IADSketchFigure can be a IADSketchLine or IADSketchCircularArc etc depending on the "FigureType".
- You can then query the geometry properties of the IADSketchLine, IADSketchCircularArc etc. (like "Start", "End", "Center", "Radius" etc.). The points you will get is in the Sketch's 2D coordinate system. These need to be transformed appropriately to convert them to 3D World coordinates (of course, the SketchPlaneNorma is a 3D vector). Unfortunately, the api does not expose an method to convert a 2d sketch point to its equivalent 3d world coordinates though we have one for going other way around (see method MapFromWorldToSketch on IADSketch interface). This should be easy to provide in an upcoming service pack or so but until that time, you need to look for a workaround if you require the sketch geometry in 3D world coordinates.
- One possible work around for this is that you could navigate the topology of the solid model (basically faces and edges) and get hold of the edge geometry you are looking for (which will all be in 3D world coordinate space).
I trust you find my answer useful.
Regards,
-Ashok