iLogic to check if Flat Pattern view is active

iLogic to check if Flat Pattern view is active

DRoam
Mentor Mentor
3,052 Views
2 Replies
Message 1 of 3

iLogic to check if Flat Pattern view is active

DRoam
Mentor
Mentor

I want an iLogic rule I'm creating to check if the Flat Pattern view is currently active for a Sheet Metal part. I want to check if it's active, not if it exists.

 

I know I can set the active view with:

 

'Flat Pattern:
ThisDoc.Document.ComponentDefinition.FlatPattern.Edit

'Folded Part:
ThisDoc.Document.ComponentDefinition.FlatPattern.ExitEdit

But how can I check the active view?

 

0 Likes
Accepted solutions (2)
3,053 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi DRoam,

 

I don't know if it's possible to know this or not, but this is what I use. It ensures the flat pattern exists and is in edit mode, before trying to do stuff with it.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oDoc = ThisApplication.ActiveEditDocument

'make sure this is a sheet metal file
If oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	
	'check for flat pattern
	Dim oCompDef As SheetMetalComponentDefinition
	oCompDef = oDoc.ComponentDefinition
	
	If oCompDef.HasFlatPattern = False Then
		Try 
			'create flat pattern
			oCompDef.Unfold 
		Catch
			Return 'exit rule
		End Try
	Else 'if flat pattern exists
		Try
			'edit flat pattern
			oCompDef.FlatPattern.Edit 
		Catch
			Return 'exit rule
		End Try
	End If

	'now we know we have a flatpattern
	'and it is active for edits
	Try				
	' do something here
	' then flip back to folded model	
	oCompDef.FlatPattern.ExitEdit	
	Catch

	End Try

End If



 

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 3 of 3

DRoam
Mentor
Mentor
Accepted solution

So my motivation for wanting to check the Active View was this: I have a rule which gets the Flat Pattern extents, and the lines of code which do so (SheetMetal.FlatExtentsLength and SheetMetal.FlatExtentsWidth) automatically create the Flat Pattern and switch to it if it didn't already exist. However, I wanted the Part to be in the same View after runnng the rule that it was in before running the rule.

 

I thought the way to do that was to check if the Flat Pattern was the active view before running my code, and if so then leave it after capturing the extents, but if not then switch back to the Folded Part view after capturing the extents.

 

However, I didn't think about this fact: My code will switch the active view to the Flat Pattern if and only if the Flat Pattern didn't already exist before running my code. So I don't actually have to know if the Flat Pattern view was active; I can simply check if it exists prior to running my code. If it does, my active view will not be switched, so that's that. But if it does not exist, I can be sure my active view will be switched to the Flat Pattern, and I'll need to switch it back.

 

So, I just added these lines to my rule:

 

 

If oCompDef.HasFlatPattern = False Then _CreatedFP = True

'Capture Extents (these will switch the active view to the Flat Pattern if and only if it doesn't already exist)
EX=SheetMetal.FlatExtentsLength
EY=SheetMetal.FlatExtentsWidth

'Do stuff with EX and EY

If _CreatedFP = True Then oCompDef.FlatPattern.ExitEdit()

 

So once again, I was just overcomplicating things Smiley Wink

 

It might be nice if there were a way to check the current active view for Sheet Metal parts, but in this case I was able to do what I need without it.

 

0 Likes