Hi Just wondering if anyone can answer my stupid question. I am just wondering how to change the orientation of a sketch in VB.net. I have no worries in VBA but the command to set the orientation and origin don't seem to work in VB.net.
If someone can help me sort out this little query I would be greatly appreciative.
Regards
Dan
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
Hi ALink
Thanks for your time. Below is the VBA code I am trying to get working in VB.net. Basically it is nearlly identical to a sample I found somewhere.
' Set the origin point to use the center point work point.
oSketch.OriginPoint = oPartCompdef.WorkPoints.Item(1)
' Set the axis to to the Y axis oSketch.
AxisEntity = oPartCompdef.WorkAxes(2)
Cheers
Dan
These functions provide similar functionality as the "Edit Coordinate System" command that you access by right-clicking on a sketch in the browser. Below is some sample code that creates a part with a sketch and then uses the properties to reorient the sketch.
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Dim invApp As Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") Dim partDoc As Inventor.PartDocument = invApp.Documents.Add(Inventor.DocumentTypeEnum.kPartDocumentObject, _ invApp.FileManager.GetTemplateFile(Inventor.DocumentTypeEnum.kPartDocumentObject)) Dim partDef As Inventor.PartComponentDefinition = partDoc.ComponentDefinition Dim tg As Inventor.TransientGeometry = invApp.TransientGeometry ' Create a work point in space. Dim wp As Inventor.WorkPoint = partDef.WorkPoints.AddFixed(tg.CreatePoint(5, 2, 3)) ' Create a sketch on the X-Y work plane. Dim sketch As Inventor.PlanarSketch = partDef.Sketches.Add(partDef.WorkPlanes.Item(3)) ' Draw a line in the X direction on the sketch. sketch.SketchLines.AddByTwoPoints(tg.CreatePoint2d(0, 0), tg.CreatePoint2d(5, 0)) ' Set the axis entity to be the Y work axis. sketch.AxisEntity = partDef.WorkAxes.Item(2) sketch.OriginPoint = wp End Sub
Thanks Brian
The only thing I had wrong was that I had my sketch as a sketch instead of a planarsketch. VB.net is a lot less forgiving than VBA.
Thanks again
Dan