- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working an Application on Inventor. I need to select a face of a part in assembly and create a sketch on it.
The sketches.add command works fine on a Work Plane, but always error with a selected face.
Here is part of my code, i can't figure out where is worry with it
Dim assDoc As AssemblyDocument = oapp.ActiveDocument
Dim assdocdef As AssemblyComponentDefinition
assdocdef = assDoc.ComponentDefinition
' Call the Pick method and set the filter to pick any face.
Dim oSelect As New Class1(oapp)
Dim oFace As Face
oFace = oSelect.Pick(SelectionFilterEnum.kPartFaceFilter)
'start edit mode on the first part in assembly
Dim oOcc As ComponentOccurrence = assdocdef.Occurrences.Item(1)
oOcc.Edit()
' access the part document component definition
Dim oPartCompDef As PartComponentDefinition = oOcc.Definition
' create a new sketch
Dim oSketch As Sketch
'the code below can't work
'oSketch = oPartCompDef.Sketches.Add(oFace)
'the code below can't work too
'oSketch = assDoc.ComponentDefinition.Sketches.Add(oFace)
'but it works good if i select a work plane
oSketch = oPartCompDef.Sketches.Add(oPartCompDef.WorkPlanes.Item("Work Plane1"))
oSketch.Edit()Maybe because Inventor can not know the face belong to the part? I have already tried a few days but still can't fix it.
2. And another question pls, it that possible, for example:
Here is a cube, and of course with 6 faces, named face 1 to face 6
For each face there is a sketch on it, called sketch1 to sketch 6
Is that possible, if i pick face 1 and want to sketch something on it, the programm will know, i selected face 1 and there is already sketch 1 on there.
So it will run the "edit sketch" command on sketch 1 instead of create a new sketch?
Thanks very much for your help!!
Solved! Go to Solution.
