Flat or folded model

Flat or folded model

TONELLAL
Collaborator Collaborator
1,539 Views
5 Replies
Message 1 of 6

Flat or folded model

TONELLAL
Collaborator
Collaborator

Hello,

I'm looking for an iLogic rule or VBA code to display the folded or unfolded model of a sheet metal part.

When you have a sheet metal part with its flat model, you can double clic in the browser to activate the flat or folded model. How can I do the same thing in VBA or iLogic ?

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

MechMachineMan
Advisor
Advisor
Use programming help and search SheetMetalComponentDefinition or FlatPattern Property and get it's parent.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 6

philippe.leefsma
Alumni
Alumni

SheetMetalComponentDefinition.FlatPattern.Edit()

 

As suggested, check the help files for SheetMetalComponentDefinition  & FlatPattern object, for example if the sheet metal part hasn't been unfolded, theSheetMetalComponentDefinition.FlatPattern property returns Nothing, you need to invoke Unfold method.

 

You can check using SheetMetalComponentDefinition.HasFlatPattern.

 

Hope that helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 4 of 6

Anonymous
Not applicable
Accepted solution

code your looking for is like this:

dim oPart as partdocument

oPart = thisapplication.activedocument

dim oShtCompDef as SheetMetalComponentDefinition

oShtCompDef = oPart.ComponentDefinition 'make sure oPart is a sheet metal part

If oShtCompDef.HasFlatPattern = False Then

    oShtCompDef.Unfold()

End If

 

and these commands to see the folded and unfolded model 

 

 

oShtCompDef.FlatPattern.ExitEdit()

 

oShtCompDef.FlatPattern.Edit()

Message 5 of 6

Anonymous
Not applicable
that's vb.net code, in VBA you might have to use Set oPart = ... and Set oShtCompDef = .... if I remember correctly
0 Likes
Message 6 of 6

TONELLAL
Collaborator
Collaborator

Ok, this is exactly what I was looking for.

 

Thanks for your help !

0 Likes