- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi guys,
I'm wondering if it is possible to convert drawing views of folded sheet metal parts to a flat pattern view by using iLogic.
The reason I'm asking is because we have to place lots of sheet metal on a drawing. When we place a sheet metal part on our drawing, the view option automatically chooses the folded model as default and we have to change it to flat pattern. The reason why this is annoying is because I automated a large part of the sheet metal drawings, but this part still has to be done manually....
I hope someone can help me out
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hallo Jesse,
Maybe you can use this:
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 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 oSMDef.FlatPattern.FlipBaseFace Else 'do nothing End If End If 'Define IDW Template File Location oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Temp\my template.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 '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 'kDefaultViewOrientation = 10753 (Default folded Or flat pattern view) 'kFlatPivotRightViewOrientation = 10767 'kFlatPivotLeftViewOrientation = 10768 'kFlatPivot180ViewOrientation = 10769 'kFlatBacksideViewOrientation = 10770 'kFlatBacksidePivotRightViewOrientation = 10771 'kFlatBacksidePivotLeftViewOrientation = 10772 'kFlatBacksidePivot180ViewOrientation = 10773
I already changed it a bit, it will now only make a view from the flat pattern from the open sheetmetal part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Robert,
Thanks for the quick answer!
I already found this piece of code multiple times, but it's not exactly the one I am looking for...
What this piece of code does is to open a new drawing and place views of the part which is open at the moment. What I have is multiple sheet metal parts on one drawing (in folded state unfortunately). I already have a piece of code that places a custom view label above each selected view and changes every view to a selected scale.
What I want extra is an conversion of the view from sheetmetal folded to sheetmetal flat pattern. If a conversion isn't possible, maybe the code can place a new (flat pattern) view --> delete the already placed folded view --> place label and scale at the new flat pattern view.
I hope someone can help me out...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey, how about this:
Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
For Each oSheet As Sheet In oDoc.Sheets
If oSheet.DrawingViews.Count = 0 Then Continue For
For Each oView As DrawingView In oSheet.DrawingViews
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oModel.DocumentSubType.DocumentSubTypeID <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Add("SheetMetalFoldedModel", False)
Dim oPoint As Point2D = oView.Position
Dim oViewStyle As DrawingViewStyleEnum = oView.ViewStyle
Dim oScale As Double = oView.Scale
Dim oOri As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kDefaultViewOrientation
oSheet.DrawingViews.AddBaseView(oModel, oPoint, oScale, oOri, oViewStyle, , , oOptions)
oView.Delete()
Next
Next
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Mike!
Thank you very much for the answer. I adjusted your code a little bit so it will work for selected views only. I hope this might be useful for others.
Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oView As DrawingView
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
MessageBox.Show("Select view(s)", "Attention!")
Exit Sub
End If
For Each oSheet As Sheet In oDoc.Sheets
If oSheet.DrawingViews.Count = 0 Then Continue For
For Each oView In oSSet
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oModel.DocumentSubType.DocumentSubTypeID <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Add("SheetMetalFoldedModel", False)
Dim oPoint As Point2D = oView.Position
Dim oViewStyle As DrawingViewStyleEnum = oView.ViewStyle
Dim oScale As Double = oView.Scale
Dim oOri As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kDefaultViewOrientation
oSheet.DrawingViews.AddBaseView(oModel, oPoint, oScale, oOri, oViewStyle, , , oOptions)
oView.Delete()
Next
Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Mike,
Just one more question. Right now, when i have more than one sheet, all the new views are placed on the first sheet. I would like the new views to be placed on the sheet where the folded model is placed...
Is this possible?
Thx in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Do you want to select the views that should be processed for each sheet?
If so, you have to move the selection pick to the "For each sheet" loop and prompt user for input.
I don't see how you could pre-select views from multiple sheets... do you want to only select the views from first sheet and process all views from all the other sheets?
Or is there a condition for the views that we could code in?
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
What i basically want to happen is the following;
- Manually place folded parts on drawing (lets say on sheet 2)
- Select all the folded parts views on sheet 2
- Run the rule to add the flat pattern of the parts on the same sheet as the folded views and delete the folded views
What is happening with the code i mentioned above;
- Manually place folded parts on drawing (lets say on sheet 2)
- Select all the folded parts views on sheet 2
- Run the rule
- Flat pattern of the parts are created and placed on sheet 1 and the folded views are deleted (not what i want)
So, is there a way to direct the new view to the sheet and position of the original folded view?
Could you maybe give a direction in the following sentence?
oSheet.DrawingViews.AddBaseView(oModel, oPoint, oScale, oOri, oViewStyle, , , oOptions)
Or is there an other way to do it?
Greetings
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Alright, here you go. The rule will now only process the selected views on the active sheet and only if the source model is a sheet metal (that's the document type check).
Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oView As DrawingView
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
MessageBox.Show("Select view(s)", "Attention!")
Exit Sub
End If
Dim oSheet As Sheet = oDoc.ActiveSheet
If oSheet.DrawingViews.Count = 0 Then Continue For
For Each oView In oSSet
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oModel.DocumentSubType.DocumentSubTypeID <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Add("SheetMetalFoldedModel", False)
Dim oPoint As Point2D = oView.Position
Dim oViewStyle As DrawingViewStyleEnum = oView.ViewStyle
Dim oScale As Double = oView.Scale
Dim oOri As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kDefaultViewOrientation
oSheet.DrawingViews.AddBaseView(oModel, oPoint, oScale, oOri, oViewStyle, , , oOptions)
oView.Delete()
Next
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods