Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic. How to place flat pattern on the drawing?

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
achmidt
6356 Views, 11 Replies

iLogic. How to place flat pattern on the drawing?

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
Tags (1)
11 REPLIES 11
Message 2 of 12
Curtis_Waguespack
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

 

Message 3 of 12
Curtis_Waguespack
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

 

Message 4 of 12
achmidt
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
Message 5 of 12
Curtis_Waguespack
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


Message 6 of 12
jdkriek
in reply to: Curtis_Waguespack

Very nice Curtis!

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


Message 7 of 12
achmidt
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
Message 8 of 12
johnkeller
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!!

Message 9 of 12
erik.vold
in reply to: achmidt

I know this is a really old post, but do you have a version of this that works in newer versions of inventor.

Just an Intern doing his best.
Message 10 of 12
ramji.m
in reply to: erik.vold

The above codes work in the latest version too.

And I am looking for an option to name all the views all in the same code

something like this

oView5.Label.FormattedText = "ISOMETRIC VIEW"

though i am not getting any error but the name is not getting changed as well.

 

can somebody help me ??

 

Note: I don't want to use orient type function as its naming my flat pattern as front view 

Message 11 of 12
AMISTRYZ5Q34
in reply to: achmidt

Your code is really nice and helpful.

I have one query regarding the scaling. Can we make the code with a prompt box that will ask users to enter for the scale as well?

Thank you in advance

Message 12 of 12
karl44GV5
in reply to: achmidt

How do i make a drawing temp for this to work?

 

I have drawing temp but it dosent seen to work. please see attached Error 

 

Thanks in advance.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report