Help with iLogic to create automated 2D drawings

Help with iLogic to create automated 2D drawings

Anonymous
Not applicable
1,742 Views
3 Replies
Message 1 of 4

Help with iLogic to create automated 2D drawings

Anonymous
Not applicable

I have coded with iLogic before but not extensively. What I need help with is I need to create a code which will produce 2D drawings when basic models are used. Anyone any knowledge in this?

0 Likes
1,743 Views
3 Replies
Replies (3)
Message 2 of 4

Rob67ert
Collaborator
Collaborator

Maybe this will help:

 

SyntaxEditor Code Snippet

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 
Dim oView5 as DrawingView 

'Ask for scale
ViewScale = InputBox("Scale = 1 op        (voor 1:20 vul 0.02 in)", "Vul schaal in", "1")

'ViewScale = 0.02

'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
        oSMDef.FlatPattern.FlipBaseFace
        Else
        'do nothing
        End If 
    End If
    
    'Define IDW Template File Location
    oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Cad_Settings\Inventor_Support_files 2018\Templates\Standard.idw", 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
oPoint5 = ThisApplication.TransientGeometry.CreatePoint2d(25, 25)' Iso view
    
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)
oView5 = oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint5, kShadedDrawingViewStyle, ViewScale)
End If
Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi Robert,

 

That code didn't run, it kept bringing up this error "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))" and I have no idea how to fix it.

0 Likes
Message 4 of 4

Rob67ert
Collaborator
Collaborator
You have to define your template drawing. It is commented in the iLogic rule
Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes