Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
130 Posts
4 Kudos
Registered: ‎07-21-2011
Post 1 of 8
Accepted Solution

iLogic. How to place flat pattern on the drawing?

1505 Views, 7 Replies
04-11-2012 09:40 AM

Hello,

 

I attached the iLogic code which is automatically creating dwg drawing (script borrowed from one of the discussion group users), also it creates 4 views. I`m just wondering how to add flat pattern ? 

 

Thanks,

Alex.

 

 

Inventor Virtual Parts Addin

http://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3Avirtualpartsadd-in_windows32and64%3Aen

Hi achmidt,

 

Here is a variation of your rule that places a flat pattern in the default orientation. See attached .txt file if copying and pasting the code directly causes issues.

 

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

 

Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum
Dim oDrawingDoc as DrawingDocument
Dim oPartDoc as Document
Dim oSheet As sheet
Dim oView1 as DrawingView
Dim oView2 as DrawingView
Dim oView3 as DrawingView
Dim oView4 as DrawingView
ViewScale = 1
'Ask to create drawing?
dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection")
If dwgQuery = vbYes Then
oPartDoc = ThisDoc.Document
'Define IDW Template File Location
'oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Temp\my template.idw", True)
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True)
oSheet = oDrawingDoc.Sheets.Item(1)
' Create a new NameValueMap object
Dim oBaseViewOptions As NameValueMap
oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
'True = folded view
'False = flat pattern view
oBaseViewOptions.Add("SheetMetalFoldedModel", False)
'Define 2d view bottom left corner points for four views
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(9, 10) ' front view
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(9, 14) ' top view
oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(18, 10)' right view
oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(20, 18)' flat pattern
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineDrawingViewStyle, "My View")
oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle, ViewScale)
oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, ViewScale)
'kDefaultViewOrientation = 10753 (default folded or flat pattern view)
'kFlatPivotRightViewOrientation = 10767
'kFlatPivotLeftViewOrientation = 10768
'kFlatPivot180ViewOrientation = 10769
'kFlatBacksideViewOrientation = 10770
'kFlatBacksidePivotRightViewOrientation = 10771
'kFlatBacksidePivotLeftViewOrientation = 10772
'kFlatBacksidePivot180ViewOrientation = 10773
oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)
End If

 

Hi achmidt,

 

Here's another variation that checks the model to see if it is a sheetmetal part and then checks for a flat pattern and then generates one if it doesn't find it.

 

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

 

 

Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum

Dim oDrawingDoc as DrawingDocument    
Dim oPartDoc as Document
Dim oSheet As sheet
Dim oView1 as DrawingView
Dim oView2 as DrawingView
Dim oView3 as DrawingView
Dim oView4 as DrawingView

ViewScale = 1

'Ask to create drawing?
dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection")

If dwgQuery = vbYes Then
    oPartDoc = ThisDoc.Document
    
       
    'Check to see if part is a sheetmetal part
    If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
        'do nothing
    Else
        '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
        oSMDef.FlatPattern.ExitEdit
        Else
        'do nothing
        end if
    End if
        
    
    'Define IDW Template File Location
    'oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Temp\my template.idw", True)
    oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True)
   oSheet = oDrawingDoc.Sheets.Item(1)
    
      ' Create a new NameValueMap object
  Dim oBaseViewOptions As NameValueMap
  oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
 
 'True = folded view
 'False = flat pattern view
  oBaseViewOptions.Add("SheetMetalFoldedModel", False)
   
'Define 2d view bottom left corner points for four views
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(9, 10) ' front view
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(9, 14) ' top view
oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(18, 10)' right view
oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(20, 18)' flat pattern
    
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineDrawingViewStyle, "My View")
oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle, ViewScale)
oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, ViewScale)  
oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)
End If

 

Thanks a lot!  Code worked. Attached is final iLogic script for creating 4 views and a flat pattern. I`ll have a lot more to do. Now I need to add overall dimensions, measure hole diameter, add ordinate dim`s for the baffle holes....

Curtis, I`m just wondering where to get all these API functions and descriptions of these variables? Is there any book? I searched internet and I couldn`t find anything for the inventor API.

 

Thanks,

Alex.

Hi achmidt,

 

Thanks for posting back your finished code. I'm certain it'll help someone in the future.

 

I think you should be able to find the Autodesk Inventor API Help file installed on your machine at some location like:

C:\Program Files\Autodesk\Inventor 20xx\Help

Look for a file named admapi_xx_0.chm

where the xx is the inventor version.

Edit:

See this link for better directions to the location of the .chm file

http://forums.autodesk.com/t5/Autodesk-Inventor/Where-is-the-API-Help-in-the-Local-Help-file-or-WikiHelp-for/td-p/3013170

 

 

Also see this link:

http://usa.autodesk.com/adsk/servlet/index?id=1079044&siteID=123112

 

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


*Expert Elite*
3,002 Posts
1,704 Kudos
Registered: ‎03-08-2006
Post 2 of 8

Re: iLogic. How to place flat pattern on the drawing?

04-11-2012 02:08 PM in reply to: achmidt

Hi achmidt,

 

Here is a variation of your rule that places a flat pattern in the default orientation. See attached .txt file if copying and pasting the code directly causes issues.

 

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

 

Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum

Dim oDrawingDoc as DrawingDocument    
Dim oPartDoc as Document
Dim oSheet As sheet
Dim oView1 as DrawingView
Dim oView2 as DrawingView
Dim oView3 as DrawingView
Dim oView4 as DrawingView 


ViewScale = 1

'Ask to create drawing?
dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection")

If dwgQuery = vbYes Then
    oPartDoc = ThisDoc.Document
    
    'Define IDW Template File Location
    'oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Temp\my template.idw", True)
    oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True)
   oSheet = oDrawingDoc.Sheets.Item(1)
    
      ' Create a new NameValueMap object
  Dim oBaseViewOptions As NameValueMap
  oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
 
 'True = folded view 
 'False = flat pattern view
  oBaseViewOptions.Add("SheetMetalFoldedModel", False) 
   
'Define 2d view bottom left corner points for four views
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(9, 10) ' front view
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(9, 14) ' top view
oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(18, 10)' right view
oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(20, 18)' flat pattern
    
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineDrawingViewStyle, "My View")
oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle, ViewScale)
oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, ViewScale)  

'kDefaultViewOrientation = 10753 (default folded or flat pattern view)
'kFlatPivotRightViewOrientation = 10767
'kFlatPivotLeftViewOrientation = 10768
'kFlatPivot180ViewOrientation = 10769
'kFlatBacksideViewOrientation = 10770
'kFlatBacksidePivotRightViewOrientation = 10771
'kFlatBacksidePivotLeftViewOrientation = 10772
'kFlatBacksidePivot180ViewOrientation = 10773 

oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)
End If

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





*Expert Elite*
3,002 Posts
1,704 Kudos
Registered: ‎03-08-2006
Post 3 of 8

Re: iLogic. How to place flat pattern on the drawing?

04-11-2012 02:21 PM in reply to: achmidt

Hi achmidt,

 

Here's another variation that checks the model to see if it is a sheetmetal part and then checks for a flat pattern and then generates one if it doesn't find it.

 

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

 

 

Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum

Dim oDrawingDoc as DrawingDocument    
Dim oPartDoc as Document
Dim oSheet As sheet
Dim oView1 as DrawingView
Dim oView2 as DrawingView
Dim oView3 as DrawingView
Dim oView4 as DrawingView

ViewScale = 1

'Ask to create drawing?
dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection")

If dwgQuery = vbYes Then
    oPartDoc = ThisDoc.Document
    
       
    'Check to see if part is a sheetmetal part
    If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
        'do nothing
    Else
        '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
        oSMDef.FlatPattern.ExitEdit
        Else
        'do nothing
        end if
    End if
        
    
    'Define IDW Template File Location
    'oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Temp\my template.idw", True)
    oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "", True)
   oSheet = oDrawingDoc.Sheets.Item(1)
    
      ' Create a new NameValueMap object
  Dim oBaseViewOptions As NameValueMap
  oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap
 
 'True = folded view
 'False = flat pattern view
  oBaseViewOptions.Add("SheetMetalFoldedModel", False)
   
'Define 2d view bottom left corner points for four views
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(9, 10) ' front view
oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(9, 14) ' top view
oPoint3 = ThisApplication.TransientGeometry.CreatePoint2d(18, 10)' right view
oPoint4 = ThisApplication.TransientGeometry.CreatePoint2d(20, 18)' flat pattern
    
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, ViewScale,kFrontViewOrientation, kHiddenLineDrawingViewStyle, "My View")
oView2 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle, ViewScale)
oView3 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, ViewScale)  
oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)
End If

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Distinguished Contributor
130 Posts
4 Kudos
Registered: ‎07-21-2011
Post 4 of 8

Re: iLogic. How to place flat pattern on the drawing?

04-12-2012 07:15 AM in reply to: Curtis_Waguespack

Thanks a lot!  Code worked. Attached is final iLogic script for creating 4 views and a flat pattern. I`ll have a lot more to do. Now I need to add overall dimensions, measure hole diameter, add ordinate dim`s for the baffle holes....

Curtis, I`m just wondering where to get all these API functions and descriptions of these variables? Is there any book? I searched internet and I couldn`t find anything for the inventor API.

 

Thanks,

Alex.

Inventor Virtual Parts Addin

http://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3Avirtualpartsadd-in_windows32and64%3Aen
*Expert Elite*
3,002 Posts
1,704 Kudos
Registered: ‎03-08-2006
Post 5 of 8

Re: iLogic. How to place flat pattern on the drawing?

04-12-2012 08:26 AM in reply to: achmidt

Hi achmidt,

 

Thanks for posting back your finished code. I'm certain it'll help someone in the future.

 

I think you should be able to find the Autodesk Inventor API Help file installed on your machine at some location like:

C:\Program Files\Autodesk\Inventor 20xx\Help

Look for a file named admapi_xx_0.chm

where the xx is the inventor version.

Edit:

See this link for better directions to the location of the .chm file

http://forums.autodesk.com/t5/Autodesk-Inventor/Where-is-the-API-Help-in-the-Local-Help-file-or-Wiki...

 

 

Also see this link:

http://usa.autodesk.com/adsk/servlet/index?id=1079044&siteID=123112

 

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




  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





*Expert Elite*
546 Posts
106 Kudos
Registered: ‎03-29-2007
Post 6 of 8

Re: iLogic. How to place flat pattern on the drawing?

04-14-2012 11:24 PM in reply to: Curtis_Waguespack

Very nice Curtis!

Jonathan D. Kriek
Manufacturing Solutions Engineer
KETIV Technologies, Inc.



_____________________________________________________
Did I help you? Please choose Accept as Solution or Kudos below
Distinguished Contributor
130 Posts
4 Kudos
Registered: ‎07-21-2011
Post 7 of 8

Re: iLogic. How to place flat pattern on the drawing?

10-11-2012 06:31 AM in reply to: Curtis_Waguespack

Curtis,

 

Quick question,

 

how to change the line below so flat pattern reflects the bends? I assume kHiddenLineDrawingViewStyle needs to be replaced with a different statement?

 

oView4 = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint4, ViewScale,kDefaultViewOrientation, kHiddenLineDrawingViewStyle,,, oBaseViewOptions)

 

Also is it possible and how to change drawing template so bend extents is checked by default?

 

Thank you so much!

Alex.

 

 

 

 

Inventor Virtual Parts Addin

http://apps.exchange.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3Avirtualpartsadd-in_windows32and64%3Aen
Active Member
6 Posts
1 Kudo
Registered: ‎11-24-2013
Post 8 of 8

Re: iLogic. How to place flat pattern on the drawing?

11-24-2013 08:35 AM in reply to: achmidt

Hi Curtis,

 

which is the individual snippet that only search and in case generate the flat pattern in the sheet metal part?

 

Thank you!!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!