iFeature Rotation Blues

iFeature Rotation Blues

Anonymous
Not applicable
447 Views
5 Replies
Message 1 of 6

iFeature Rotation Blues

Anonymous
Not applicable
Sanjay,

I have successfully built an iFeature import tool for a special set of iFeatures. The import rotation is wrong 80 percent of the time.

Is there any way I can launch the Edit iFeature Inputs dialog.
on an iFeature created through the API?

I've been trying the controldefinition "PartiFeatureFileEditCmd"
without success. Seems I cannot programmially select it even with the BrowserNode.DoSelect method.

Any help out there?

Regards,
0 Likes
448 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Tom,

For selecting the iFeature, you need to find the corresponding
ReferenceFeature and pass that into SelectSet.Select. Also, you had the
incorrect internal name for the context menu command - use
"PartiFeatureEditCtxCmd" instead. Here is a sample that assumes that the
first feature in the tree is an iFeature:

Sub LaunchiFeatureEdit()

Dim odoc As PartDocument
Set odoc = ThisApplication.ActiveDocument

Dim odef As PartComponentDefinition
Set odef = odoc.ComponentDefinition

odoc.SelectSet.Select odef.Features(1)

Dim octrldef As ControlDefinition
Set octrldef =
ThisApplication.CommandManager.ControlDefinitions.Item("PartiFeatureEditCtxCmd")

octrldef.Execute

End Sub

Sanjay-

wrote in message news:5186823@discussion.autodesk.com...
Sanjay,

I have successfully built an iFeature import tool for a special set of
iFeatures. The import rotation is wrong 80 percent of the time.

Is there any way I can launch the Edit iFeature Inputs dialog.
on an iFeature created through the API?

I've been trying the controldefinition "PartiFeatureFileEditCmd"
without success. Seems I cannot programmially select it even with the
BrowserNode.DoSelect method.

Any help out there?

Regards,
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thank you Sanjay,

That works all right. I had a problem with the keyboard preview
seemed to be still on the userform that launched the EditIfeature dialog.

I played around with it for a bit and found that if I used:
'thisapplication.Activedocument.Activate'
after the 'controldef.execute' it puts the focus on the editifeature dialog as desired.

All this being said it is still an ugly Rube Goldberg.
and selecting the right ifeature and rotation is still more random than not.

My goal is to import a right angle triangle cut ifeature into a target face and have it always be rotated to the upper left hand corner of a face. (With the user designating the edges that will be used as"Top" and "Left")

I've created quite a few test ifeatures that use different reference points and edges to be selected. The result
never works in all cases.

+++
I am using Ifeatures specifically because they generate a separate layer on flat pattern dxf export. Otherwise I would be tempted to create what I need as a regular feature programmatically and have a lot more control over the process.

Other than creating a regular feature, Creating an iFeature from it, deleting the original, and then importing the iFeature back in I cannot think of a way to do it that way.
+++

Any thoughts on how I can achieve my goal?
0 Likes
Message 4 of 6

Anonymous
Not applicable
Tom,

The problem here is that an iFeature doesn't really have an origin of its
own. So it is not possible to precisely place an iFeature. In order to do
so, you must make sure that the iFeature is dependent on other geometry
(such as a work points) when you are creating it. The best way to do so is
to make the original sketch of the iFeature dependent on workpoints (just
one if only position placement is required, or upto 3 - that define an
origin and 2 axes - if both position and orientation are required). You can
make the sketch dependent on work points by projecting the workpoints onto
the sketch. Now, when you place the iFeature into a part, you need to select
equivalent geometry to place the iFeature thus giving you the desired
position/orientation.

Hope this helps,
Sanjay-


wrote in message news:5187705@discussion.autodesk.com...
Thank you Sanjay,

That works all right. I had a problem with the keyboard preview
seemed to be still on the userform that launched the EditIfeature dialog.

I played around with it for a bit and found that if I used:
'thisapplication.Activedocument.Activate'
after the 'controldef.execute' it puts the focus on the editifeature dialog
as desired.

All this being said it is still an ugly Rube Goldberg.
and selecting the right ifeature and rotation is still more random than not.

My goal is to import a right angle triangle cut ifeature into a target face
and have it always be rotated to the upper left hand corner of a face.
(With the user designating the edges that will be used as"Top" and "Left")

I've created quite a few test ifeatures that use different reference points
and edges to be selected. The result
never works in all cases.

+++
I am using Ifeatures specifically because they generate a separate layer on
flat pattern dxf export. Otherwise I would be tempted to create what I need
as a regular feature programmatically and have a lot more control over the
process.

Other than creating a regular feature, Creating an iFeature from it,
deleting the original, and then importing the iFeature back in I cannot
think of a way to do it that way.
+++

Any thoughts on how I can achieve my goal?
0 Likes
Message 5 of 6

Anonymous
Not applicable
Thank you for the reply,

I found a form of iFeature that is more stable for this situation. It uses a reference plane, line, and point.

The user still has to make an arbitrary choice of left or right though.

Sanjay, I realize that the iFeature itself does not have an origin but we do (or can) know the rotation as regards the x,y coordinate system of the source feature. If we know that and the face we are placing it on can't we determine the rotation angle necessary for the ifeature? The user would still have to detemine Left or Right but at least he wouldn't have to guess at the rotation. As I am creating the iFeature programmatically I can do some juggling of data.

Knowns:
Source face normal (In this case (0,0,1) front view)
Source Coordinate system
Source X vector
Target face normal
Target Coordinate system.
Target User Selected X vector

Possible?
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hmmm, Okay I tried my idea and used the ToAngle method with the following criteria:

oBaseVector = 1,0,0 'Front view unitvector from left corner to right corner (original feature saved as an iFeature)

oVector 'unitvector based on selected Edge and Vertex.

When I use:
iFeatAngle = oBaseVector.AngleTo(oVector)

I get a number from 0 to PI. never over that. is that the return range? I was hoping to be able to get from 0 to 2(PI) so I could determine upto 270 degrees.

Also when using the oiFeatPlaneInput.SetPosition(oPoint, oVector.AsVector, iFeatAngle) method.

is the input angle in radians?

So far set position fails when I try to use it.

If I am using setposition should I not apply the rest of the required iFeature selected items?

Example:
'-------------------
Private Sub cmdOK_Click()

Dim oPrt As PartDocument
Dim oCompDef As PartComponentDefinition
Dim sVal As String
Dim sCut As String
Dim sFile As String
Dim sPath As String

Dim feat As PartFeature
Dim oiFeatDef As iFeatureDefinition
Dim oiFeatComps As iFeatureComponents
Dim oiFeatPlaneInput As iFeatureSketchPlaneInput
Dim oiFeatEntityInput1 As iFeatureEntityInput
Dim oiFeatEntityInput2 As iFeatureEntityInput
Dim oiFeatParamInput As iFeatureParameterInput
Dim oiFeat As iFeatureComponent

Dim oGeo As TransientGeometry
Dim oPoint As Inventor.Point
Dim oVector As Inventor.UnitVector
Dim oBaseVector As Inventor.UnitVector
Dim iFeatAngle As Double

Dim Pt(2) As Double
Dim SPts(2) As Double
Dim EPts(2) As Double
Dim oSPoint As Point
Dim oEPoint As Point
Dim oVPoint As Point

Dim oCmd As Inventor.CommandManager
Dim oCtrlDef As ControlDefinition

Dim s As String
Dim i As Integer

cmdClearAll.SetFocus

Set oPrt = ThisApplication.ActiveDocument
Set oCompDef = oPrt.ComponentDefinition
Set oiFeatComps = oCompDef.ReferenceComponents.iFeatureComponents
Set oGeo = ThisApplication.TransientGeometry

'------- Create iFeature ------
sFile = "Bend_LT_Up.ide"
sPath = "C:\Program Files\Autodesk\Inventor 10\Catalog\" & sFile
Set oiFeatDef = oCompDef.ReferenceComponents.iFeatureComponents.CreateDefinition(sPath)

Set oiFeatPlaneInput = oiFeatDef.iFeatureInputs.item(1)
oiFeatPlaneInput.PlaneInput = oFace

Call oVertex.GetPoint(Pt)
Set oPoint = oGeo.CreatePoint(Pt(0), Pt(1), Pt(2))

Call oEdge.StartVertex.GetPoint(SPts)
Call oEdge.StopVertex.GetPoint(EPts)
Set oSPoint = oGeo.CreatePoint(SPts(0), SPts(1), SPts(2))
Set oEPoint = oGeo.CreatePoint(EPts(0), EPts(1), EPts(2))

If oPoint.IsEqualTo(oSPoint) Then Set oVPoint = oEPoint
If oPoint.IsEqualTo(oEPoint) Then Set oVPoint = oSPoint
Set oVector = oPoint.VectorTo(oVPoint).AsUnitVector

'Predetermined from original feature
'---
Set oBaseVector = oGeo.CreateUnitVector(1, 0, 0)
'---

iFeatAngle = oBaseVector.AngleTo(oVector)
MsgBox iFeatAngle

Call oiFeatPlaneInput.SetPosition(oPoint, oVector.AsVector, iFeatAngle)
'----

Set oiFeatEntityInput1 = oiFeatDef.iFeatureInputs.item(2)
oiFeatEntityInput1.Entity = oVertex

Set oiFeatEntityInput2 = oiFeatDef.iFeatureInputs.item(3)
oiFeatEntityInput2.Entity = oEdge

Set oiFeatParamInput = oiFeatDef.iFeatureInputs.item(4)
oiFeatParamInput.Expression = ".125 in"

'On Error Resume Next
Set oiFeat = oiFeatComps.Add(oiFeatDef)
'------- End Create iFeature ------

Set oCmd = ThisApplication.CommandManager
Set oCtrlDef = oCmd.ControlDefinitions("PartiFeatureEditCtxCmd")

Call oPrt.SelectSet.Select(oCompDef.Features (oiFeat.Name))
oCtrlDef.Execute

Set oVertex = Nothing
Set oFace = Nothing
lblVertex.BackColor = UsedColor
lblEdge.BackColor = UsedColor
lblFace.BackColor = UsedColor

ThisApplication.ActiveDocument.Activate
End Sub
'-------------------

Puzzled but optimystic, Message was edited by: TomGroff
0 Likes