To View the Model Normal to .FlatPattern.BaseFace for DXF Export

To View the Model Normal to .FlatPattern.BaseFace for DXF Export

SevInventor
Advocate Advocate
452 Views
5 Replies
Message 1 of 6

To View the Model Normal to .FlatPattern.BaseFace for DXF Export

SevInventor
Advocate
Advocate

I have an ilogic rule for exporting the flat pattern to DXF

Before the export it asks the user if the thing has the right orientation but at that time it only shows the current View position which can be moved and rotated.

So it isn’t an indicator for correct orientation.

In Inventor 2019 there was no problem because in the flat pattern the View was never rotated and always showing normal to the flat pattern.

How can I view the standard Orientation  as in earlier versions.

Basically I want the To View the Model Normal to  .FlatPattern.BaseFace when the message box shows up.

I've tried arround with oview and ocamera and stuff but no success yet.

SevInventor_0-1702540795921.png

 

thanks

'Flip Alignment Type
' Set a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'ensure this part has a flat pattern
Dim oSMDef As SheetMetalComponentDefinition
oSMDef = oPartDoc.ComponentDefinition
If oSMDef.FlatPattern Is Nothing Then 
'create flat pattern
oSMDef.Unfold
Else
End If 

Question = MessageBox.Show("Is the orientation correct?" ,"leave it or flip?" ,MessageBoxButtons.YesNo)

If Question = vbNo Then

'oCompDef.FlatPattern.FlipBaseFace
Dim oAlignmentType As AlignmentTypeEnum
Dim oAlignedTo As Object
Dim oAlignmentDirection As Boolean

'get current alignment parameters
oSMDef.FlatPattern.GetAlignment(oAlignmentType, oAlignedTo, oAlignmentDirection) 

'toggle alignment horizontal/ vertical parameter
'kHorizontalAlignment = 64257 
'kVerticalAlignment = 64258 
If oAlignmentType = 64257  Then 
oAlignmentType = 64258
Else
oAlignmentType = 64257 
End If
oSMDef.FlatPattern.SetAlignment(oAlignmentType, oAlignedTo, oAlignmentDirection)


End If

'zoom all
ThisApplication.ActiveView.Fit

 

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

JelteDeJong
Mentor
Mentor

Just to be clear you want your users to check if the alignment settings are set correctly. And with alignment settings I mean these settings:

JelteDeJong_0-1702542606479.png

 

Maybe a bit silly but if the orientation is not correct then you can make the user change the settings himself/herself. To help them you could open the dialog for them. Something like this:

Dim doc As PartDocument = ThisDoc.Document
Dim def As SheetMetalComponentDefinition = doc.ComponentDefinition
def.Unfold()

Dim question = MessageBox.Show("Is the orientation correct? (If not correct the orientation manualy and restart this rule)", "Check orientation", MessageBoxButtons.YesNo)

If question = DialogResult.No Then

    ThisApplication.CommandManager.ControlDefinitions.Item("SheetMetalEditFlatCtxCmd").Execute()
    Return ' Exit the rule 
End If

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 6

SevInventor
Advocate
Advocate

Hello Jelte,

always nice to hear from the superstars in this forum. I've learned a lot from your contributions. Thanks.
Yes i want the same thing but without that dialog/ command.
The view can also be wrong during this dialog so it's not quite clear how the result will be as output see picture.
Its clearer if the view is perpendicular to the flat pattern.


SevInventor_0-1702544463710.png

 



0 Likes
Message 4 of 6

JelteDeJong
Mentor
Mentor
Accepted solution

Is this what you are looking for?

 

Dim doc As PartDocument = ThisDoc.Document
Dim def As SheetMetalComponentDefinition = doc.ComponentDefinition
def.Unfold()

Dim flatPattern As FlatPattern = def.FlatPattern
Dim camera = ThisApplication.ActiveView.Camera

Dim question = DialogResult.No
While question <> DialogResult.Yes

    camera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
    camera.Fit()
    camera.Apply()
    question = MessageBox.Show("Is the orientation correct? (If not correct the orientation manualy and restart this rule)", "Check orientation", MessageBoxButtons.YesNo)

    Dim orientation As FlatPatternOrientation = flatPattern.FlatPatternOrientations.ActiveFlatPatternOrientation
    ' Dim AlignmentAxis As Object = Orientation.AlignmentAxis '<-- probaly an edge

    If (orientation.AlignmentType = AlignmentTypeEnum.kVerticalAlignment) Then
        orientation.AlignmentType = AlignmentTypeEnum.kHorizontalAlignment
    Else
        orientation.AlignmentType = AlignmentTypeEnum.kVerticalAlignment
    End If

End While

''' Your code to export comes here.

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 6

SevInventor
Advocate
Advocate

Yes, almost.
I've never imagined that 

ViewOrientationTypeEnum.kFrontViewOrientation

would always be the right view but I've tested it on some sheetmetal files and it was working on all of them.

This code works for me:
Ive added:

 

def.FlatPattern.Edit

and moved the position of the message box in the code

Dim doc As PartDocument = ThisDoc.Document
Dim def As SheetMetalComponentDefinition = doc.ComponentDefinition
def.Unfold()
def.FlatPattern.Edit

Dim flatPattern As FlatPattern = def.FlatPattern
Dim camera = ThisApplication.ActiveView.Camera

Dim question = DialogResult.No
While question <> DialogResult.Yes

    camera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
    camera.Fit()
    camera.Apply()
    

    Dim orientation As FlatPatternOrientation = flatPattern.FlatPatternOrientations.ActiveFlatPatternOrientation
    ' Dim AlignmentAxis As Object = Orientation.AlignmentAxis '<-- probaly an edge

    If (orientation.AlignmentType = AlignmentTypeEnum.kVerticalAlignment) Then
        orientation.AlignmentType = AlignmentTypeEnum.kHorizontalAlignment
    Else
        orientation.AlignmentType = AlignmentTypeEnum.kVerticalAlignment
    End If
question = MessageBox.Show("Is the orientation correct? (If not correct the orientation manualy and restart this rule)", "Check orientation", MessageBoxButtons.YesNo)
End While



Thank you Jelte


0 Likes
Message 6 of 6

SevInventor
Advocate
Advocate

better:

Dim doc As PartDocument = ThisDoc.Document
Dim def As SheetMetalComponentDefinition = doc.ComponentDefinition
def.Unfold()
def.FlatPattern.Edit

Dim flatPattern As FlatPattern = def.FlatPattern

Dim camera = ThisApplication.ActiveView.Camera
    camera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
    camera.Fit()
    camera.Apply()
Dim question = DialogResult.No
question = MessageBox.Show("Is the orientation correct? " & vbCr & vbCr &
"On ESC correct the orientation manualy and restart this rule", "Check orientation",  MessageBoxButtons.YesNoCancel)
'msgbox(question)
'While question <> DialogResult.Yes
 While question = DialogResult.No

    Dim orientation As FlatPatternOrientation = FlatPattern.FlatPatternOrientations.ActiveFlatPatternOrientation
    ' Dim AlignmentAxis As Object = Orientation.AlignmentAxis '<-- probaly an edge

    If (orientation.AlignmentType = AlignmentTypeEnum.kVerticalAlignment) Then
        orientation.AlignmentType = AlignmentTypeEnum.kHorizontalAlignment
    Else
        orientation.AlignmentType = AlignmentTypeEnum.kVerticalAlignment
    End If
	camera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
    camera.Fit()
    camera.Apply()
question = MessageBox.Show("Is the orientation correct? " & vbCr & vbCr &
"On ESC correct the orientation manualy and restart this rule", "Check orientation",  MessageBoxButtons.YesNoCancel)
End While

If question = DialogResult.Cancel Then 
	
	    ThisApplication.CommandManager.ControlDefinitions.Item("SheetMetalEditFlatCtxCmd").Execute()
    Return ' Exit the rule 
End If
0 Likes