Inventor Sheet Metal Bug?

Inventor Sheet Metal Bug?

speterso
Contributor Contributor
994 Views
5 Replies
Message 1 of 6

Inventor Sheet Metal Bug?

speterso
Contributor
Contributor

Hello again,

 

I have been having a new issue this time with sheet metal and orienting it correctly via code to get a part ready to export to DWG for machines to use.

 

My initial question is there a bug in inventor when it creates the Flat Pattern?

 

I select the A-Side for different parts but when I create the sheet metal part is seems to be random how it unfolds the initial orientation.  Which means each piece requires individual and different actions to get it oriented correctly.

 

Why does inventor unfold the sheet metal in different orientations when the Flat Pattern part is created?

 

I make sure each side I choose for the A-Side is the one I want as up by placing an embross arrow on it so I can see orientation and which side is pulled through so it is not flipped on Flat Pattern creation.  The issue is as I make different parts even though it seems to be the same in creation sequence to make the same part, when I create the Flat Pattern it sometimes rotates so my arrow is up or sometimes down sometimes it performs other rotations or flips it seems to have no logical reason why it would not create a flat pattern always with the same effect.  However it does consistently do the same action to the same part no matter how many times I remove the flat pattern and recreate it for a specific part.

 

What am I missing in any definitions so a flat pattern generates the same always.  Like I said I can create the part multiple times each seems to have a mind(setting) of it's own when it comes to the initial orientation when the flat pattern is created.  What needs to be set to brain wash these parts to all act the same instead of different.  I thought A-Side would be all I needed to do.  That way I can perform the same orientation process to each part to get it flipped correctly for the machines.  It is proving impossible to do when the initial flat pattern has nothing common to work off of.

 

Any help would be helpful.

 

Thanks

 

Shannon

0 Likes
Accepted solutions (1)
995 Views
5 Replies
Replies (5)
Message 2 of 6

t_remal
Autodesk
Autodesk

Hi Shannon,

 

the initial Flat Pattern orientation is along the longest edge in Flat Pattern.

If you right click Flat Pattern in the browser and choose Edit Flat Pattern Definition, you can select a different edge for alignment.

 

Lubomir

0 Likes
Message 3 of 6

speterso
Contributor
Contributor

Hello Lubomir,

 

First thanks for getting back to me.

 

I can confirm it does not always default to the longest side in Inventor 2017, I have for instance a drawing I select A-Side but it will choose some short edge along another face not even on the A-Side.  Almost like selecting the A-Side does not effect the default alignment axis.

 

I know I can enter the Edit Flat Pattern Definitions and select a new side to use for alignment axis and I can get this to work as expected.

 

The thing is how do I do this via code only.  The task I have is to fully automate this process.  I have the engineers accepting the fact they have to first assign the A-Side to get the Flat Pattern in the correct orientation when creating the flat pattern.  They have a grain arrow embross and the arrow has to be in the correct orientation when the flat pattern is created and unfolded ie arrow is left to right the arrow must be left to right in unfolded part as well.  This way when the part is pulled into a drawing it is correct orientation without having to rotate the view cube angle in the drawing while pulling in the flat pattern part.

 

The task I can't figure out is how to set the correct alignment axis to a specific edge, apply the AlignmentType, Flip on the Alignment axis, and flip on the Base Face if needed, not sure what is all needed but should be similar for all parts or have a detectable way to get the end orientation correct for a final output.  By final output the initial flat pattern saved is not the flat pattern needed as end result with my code which is used for machining.  I need to flip the pattern and rotate accordingly, ie left to right arrow is flipped version so it is now left to right with the part flipped and the arrow is now on the back side of the flat pattern part or if arrow is up the same flip has to be performed but in the drawing need to apply a 90deg rotation, I tried to do the 90 deg rotation in the flat pattern but figured just as easy to do that in the final drawing.

 

I need the part that gets pulled into the drawing in correct format first however, so lets focus on nothing to do with rotation for now.  Just the flipping of the flat pattern via code so it works on all parts correctly.

 

I have tried many methods all to fail.

 

I figure I will need to detect the edge I want to use as an axis so I have written this code to find correct edge on A-Side:

 

SheetMetalComponentDefinition ShtMtlCompDef = PRTDoc.ComponentDefinition as SheetMetalComponentDefinition;
ShtMtlCompDef.FlatPattern.Edit();

 

Edge ShtMtlEdge = null;

 

double rightmostx = double.MinValue;
foreach (Edge tmpShtMtlEdge in ShtMtlCompDef.FlatPattern.ASideFace.ASideFace.Edges)
{
if (tmpShtMtlEdge.StartVertex.Point.X > rightmostx)
{
rightmostx = tmpShtMtlEdge.StartVertex.Point.X;
ShtMtlEdge = tmpShtMtlEdge;
}
}

 

via debugging statements I do confirm this represents the right most vertical edge on the A-Side.

 

ShtMtlEdge using debugging does now contain an edge with the correct parameters I expect

 

This next part I have done so many ways I will just list my latest attempts

 

AlignmentTypeEnum aligntype = AlignmentTypeEnum.kHorizontalAlignment;
object alignto = null;
bool aligndir = false;

ShtMtlCompDef.FlatPattern.GetAlignment(out aligntype, out alignto, out aligndir);

alignto = ShtMtlEdge;
aligntype = AlignmentTypeEnum.kVerticalAlignment;

ShtMtlCompDef.FlatPattern.SetAlignment(aligntype, alignto, aligndir);

 

This does not flip the part, it seems to just set the alignment edge, I have no idea how to confirm what this actually does.  BTW this is a hidden api method, I found this online, it does not resolve via intellisense in visual studio until after I have everything completely defined.  Afterwards intellisense works and see the method definition.

 

ShtMtlCompDef.FlatPattern.FlipBaseFace();

 

Now when this happens it does not flip correctly, as if the BaseFace is not the same face and A-Side Face or something.  So not sure what is happening here but it appears to flip on the default axis instead of the one I tried to assign.

 

ShtMtlCompDef.FlatPattern.ExitEdit();

 

Another method to do that last part is using the FlatPatternOrientation object.

 

FlatPatternOrientation FltPatOrient = ShtMtlCompDef.FlatPattern.FlatPatternOrientations.ActiveFlatPatternOrientation; 

FltPatOrient.AlignmentAxis = ShtMtlEdge;

FltPatOrient.FlipAlignmentAxis = false;

FltPatOrient.AlignmentType = AlignmentTypeEnum.kVerticalAlignment;

FltPatOrient.FlipBaseFace = true;

FltPatOrient.Activate();

ShtMtlCompDef.FlatPattern.ExitEdit();

 

This sometimes works on some files but not all of them if I switch some stuff to other settings I can get it to work on those other files but not on the original ones etc.  There is nothing for me to key off of on what to do in the FlatPatternOrientation object to figure out how to handle the orientation correctly.  Again it almost seems the Edge is not selected correctly.

 

I  have tried to select the edge as below to no solution either

 

PRTDoc.SelectSet.Select(ShtMtlEdge);

FltPatOrient.AlignmentAxis = m_InventorApp.ActiveDocument.SelectSet[1];

 

If anyone has any idea how to common-ize these tasks so they work on all flat patterns that would be great.  As I said engineers have the A-Side set so when the flat pattern is generated it is in the correct front orientation with grain arrow correctly displayed on the front to start with.  I need an end result of the flip so it is same orientation but back side is now the front side.  The problem I believe is that edge definition is incorrect and I do not know how to get it set correctly to do a vertical flip on the right most vertical edge, it seems I can choose any right most edge on any face actually as long as I do not do FlipAlignmentAxis.

 

Also I have tried to use the right most edge of the Base face via the following code

 

double rightmostx = double.MinValue;

foreach (Edge tmpShtMtlEdge in ShtMtlCompDef.FlatPattern.BaseFace.Edges)
{
if (tmpShtMtlEdge.StartVertex.Point.X > rightmostx)
{
rightmostx = tmpShtMtlEdge.StartVertex.Point.X;
ShtMtlEdge = tmpShtMtlEdge;
}
}

 

which again in my debugging I confirmed does find the right most edge of that face.

 

ofc this does not work either I get it flipping and everthing randomly rotated it seems as if the wrong edge was used still. even if I change AlignmentType to horixonalalignment still comes out wrong.

 

This is very confusing and complicated as to how Inventor uses all these pieces to generate the final output and I can't find any common ground to build an automation plugin to do this.  I can get manual common tasks to work as I want but it seems to set my edge correctly and use it as intended so I believe I am not setting the edge correctly and assigning it to the Alignment axis as needed.

 

Thanks for any help and sorry for the wall of text.

 

Shannon

 

0 Likes
Message 4 of 6

speterso
Contributor
Contributor

Some further information I have gathered today.

 

It seems the FltPatOrient.AlignmentAxis = ShtMtlEdge; only works with a Body Edge, I tried with many other edges for BaseFace, ASideFace, etc and it always sets the AlignmentAxis to null, but when I use a Body Edge it is able to set the AlignmentAxis to an Edge.

 

Now with that diagnosed.  How do I get the right most vertical edge of the Body? Is that the same as the right most edge when unfolded? What is the right most Body Edge?

 

I try to get the vertex coordinates but they do not match anything in the model how do I know what edge my code is selecting?

 

In the end I need to find the right most vertical edge of the unfolded flat pattern and set that to the AlignmentAxis.  I think if I can get that figured out the rest will fall into place.

0 Likes
Message 5 of 6

t_remal
Autodesk
Autodesk
Accepted solution

Hi,

 

you are right - I don't think A-Side affects the default alignment in current implementation, but it still should be along the longest edge.
We've encountered a few situations when that does not work, though. Would it be possible to share the dataset, so I can take a look?

 

The correct way to set Flat Pattern orientation is using FlatPattern.FlatPatternOrientations.ActiveFlatPatternOrientation. The hidden methods are legacy from the time when we didn't have support for multiple FP orientations. Please note that changing the Flat Pattern orientation through API does exactly the same thing as when you change it using the Edit Flat Pattern Definition command, so you can always use the UI to see what effect setting a specific edge would have.

 

Internally, we do two steps when we compute FP.
1. Unfold the folded body with the default alignment.
2. Align the unfolded body along the user selected edge (if present).

 

In 1, the default alignment should have the A-Side face in the front and should be aligned along the longest edge.
In 2, any reference geometry (edge) needs to be from Flat Pattern.

 

If you have the rightmost edge in the Folded part, you can align the Flat Pattern along that edge with this code:

 

    Dim oFPEdge As Edge
    Set oFPEdge = oDef.FlatPattern.GetFlatPatternEntity(oRightmostEdge)
    
    Dim oFPOrient As FlatPatternOrientation
    Set oFPOrient = oDef.FlatPattern.FlatPatternOrientations.ActiveFlatPatternOrientation
    
    oFPOrient.AlignmentAxis = oFPEdge
    oFPOrient.AlignmentType = kVerticalAlignment
    oFPOrient.FlipAlignmentAxis = True

GetFlatPatternEntity gives you the corresponding edge in the Flat Pattern (which might not be the rightmost in Flat Pattern, because it might have a different orientation).

 

Lubomir

Message 6 of 6

speterso
Contributor
Contributor

I am marking the above as a solution.

 

Set oFPEdge = oDef.FlatPattern.GetFlatPatternEntity(oRightmostEdge)

Was the secret to getting everything to work.

 

You were correct that the orientation of the flat pattern should not matter.  Although the default edge Inventor selects on some flat patterns I have are still on the short edge instead of the long edge as you predicted but I reset that edge to the known edge in the folded part edge I wanted and the magic line worked.

 

Thank you for your help

 

Shannon 

0 Likes