IV9: Looping through drawing sheets problem

IV9: Looping through drawing sheets problem

Anonymous
Not applicable
580 Views
13 Replies
Message 1 of 14

IV9: Looping through drawing sheets problem

Anonymous
Not applicable
I am using preselection to process a select set of drawing sheets, but while in the loop, if I change anything (i.e. Sheet.Name), any of the following selected sheets throws up a runtime error 5 dialog. But if I merely use debug.print to print out the info, the loop processes them all correctly. Any suggestions how I can overcome this limitation? I see something about Sheet.InternalName being consistent across changes, but have no idea how I would have to cache that info and access it later, or if that is even the best method? TIA, Bob S.
0 Likes
581 Views
13 Replies
Replies (13)
Message 2 of 14

Anonymous
Not applicable
Additionally, trying to get the Sheet.InternalName property string using Dim IName As String IName = mySheet.InternalName Debug.Print "Internal Sheet Name: " & IName I get an error message: Run-time error '445': Object doesn't support this action So I am even stumpted at trying to use this InternalName property. "Bob S." wrote in message news:41473194_2@newsprd01... >I am using preselection to process a select set of drawing sheets, but > while in the loop, if I change anything (i.e. Sheet.Name), any of the > following selected sheets throws up a runtime error 5 dialog. But if > I merely use debug.print to print out the info, the loop processes them > all correctly. > > Any suggestions how I can overcome this limitation? I see something > about Sheet.InternalName being consistent across changes, but have > no idea how I would have to cache that info and access it later, or if > that is even the best method? > > TIA, > Bob S. >
0 Likes
Message 3 of 14

Anonymous
Not applicable
Bob, The Sheet object does not support the InternalName property. (That needs to be removed). What you should use instead is the GetReferenceKey method that provides a persistent identifier for the Sheet object. Sanjay- "Bob S." wrote in message news:414734a1$1_2@newsprd01... > Additionally, trying to get the Sheet.InternalName property string using > > Dim IName As String > IName = mySheet.InternalName > Debug.Print "Internal Sheet Name: " & IName > > I get an error message: > Run-time error '445': > Object doesn't support this action > > So I am even stumpted at trying to use this InternalName property. > > "Bob S." wrote in message news:41473194_2@newsprd01... > >I am using preselection to process a select set of drawing sheets, but > > while in the loop, if I change anything (i.e. Sheet.Name), any of the > > following selected sheets throws up a runtime error 5 dialog. But if > > I merely use debug.print to print out the info, the loop processes them > > all correctly. > > > > Any suggestions how I can overcome this limitation? I see something > > about Sheet.InternalName being consistent across changes, but have > > no idea how I would have to cache that info and access it later, or if > > that is even the best method? > > > > TIA, > > Bob S. > > > >
0 Likes
Message 4 of 14

Anonymous
Not applicable
Sanjay, Is there an example of how to use GetReferenceKey method? Bob "Sanjay Ramaswamy (Autodesk)" wrote in message news:41474b4c_3@newsprd01... > Bob, > > The Sheet object does not support the InternalName property. (That needs to > be removed). What you should use instead is the GetReferenceKey method that > provides a persistent identifier for the Sheet object. > > Sanjay- > > > "Bob S." wrote in message > news:414734a1$1_2@newsprd01... >> Additionally, trying to get the Sheet.InternalName property string using >> >> Dim IName As String >> IName = mySheet.InternalName >> Debug.Print "Internal Sheet Name: " & IName >> >> I get an error message: >> Run-time error '445': >> Object doesn't support this action >> >> So I am even stumpted at trying to use this InternalName property. >> >> "Bob S." wrote in message > news:41473194_2@newsprd01... >> >I am using preselection to process a select set of drawing sheets, but >> > while in the loop, if I change anything (i.e. Sheet.Name), any of the >> > following selected sheets throws up a runtime error 5 dialog. But if >> > I merely use debug.print to print out the info, the loop processes them >> > all correctly. >> > >> > Any suggestions how I can overcome this limitation? I see something >> > about Sheet.InternalName being consistent across changes, but have >> > no idea how I would have to cache that info and access it later, or if >> > that is even the best method? >> > >> > TIA, >> > Bob S. >> > >> >> > >
0 Likes
Message 5 of 14

Anonymous
Not applicable
Bob, Here is a simple example that shows how to get a reference key for a sheet and then use that key to 'bind back' to the sheet. Run the first sub and then the second. Note that the 2nd argument in the method (KeyContext) is only required for BRep entities (Face, Edge, etc.) and not used in this case. Sanjay- Dim RefKey() As Byte Sub GetReferenceKey() Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet Set oSheet = oDoc.ActiveSheet Call oSheet.GetReferenceKey(RefKey) End Sub Sub BindUsingKey() Dim oRefKeyManager As ReferenceKeyManager Set oRefKeyManager = ThisApplication.ActiveDocument.ReferenceKeyManager Dim oObject As Object Set oObject = oRefKeyManager.BindKeyToObject(RefKey) End Sub "Bob S." wrote in message news:414757d3$1_1@newsprd01... > Sanjay, > > Is there an example of how to use GetReferenceKey method? > > Bob > > "Sanjay Ramaswamy (Autodesk)" wrote in message news:41474b4c_3@newsprd01... > > Bob, > > > > The Sheet object does not support the InternalName property. (That needs to > > be removed). What you should use instead is the GetReferenceKey method that > > provides a persistent identifier for the Sheet object. > > > > Sanjay- > > > > > > "Bob S." wrote in message > > news:414734a1$1_2@newsprd01... > >> Additionally, trying to get the Sheet.InternalName property string using > >> > >> Dim IName As String > >> IName = mySheet.InternalName > >> Debug.Print "Internal Sheet Name: " & IName > >> > >> I get an error message: > >> Run-time error '445': > >> Object doesn't support this action > >> > >> So I am even stumpted at trying to use this InternalName property. > >> > >> "Bob S." wrote in message > > news:41473194_2@newsprd01... > >> >I am using preselection to process a select set of drawing sheets, but > >> > while in the loop, if I change anything (i.e. Sheet.Name), any of the > >> > following selected sheets throws up a runtime error 5 dialog. But if > >> > I merely use debug.print to print out the info, the loop processes them > >> > all correctly. > >> > > >> > Any suggestions how I can overcome this limitation? I see something > >> > about Sheet.InternalName being consistent across changes, but have > >> > no idea how I would have to cache that info and access it later, or if > >> > that is even the best method? > >> > > >> > TIA, > >> > Bob S. > >> > > >> > >> > > > > > >
0 Likes
Message 6 of 14

Anonymous
Not applicable
Bob, Are you directly using/iterating the .SelectSet? If so, set a watch to the SelectSet.Count and see when it changes (goes to 0) Why? The SelectSet will "clear" itself sometimes if you are iterating it. If it does, you will have to transfer the items inside the selection in a collection. Cheers, Teun "Bob S." wrote in message news:41473194_2@newsprd01... > I am using preselection to process a select set of drawing sheets, but > while in the loop, if I change anything (i.e. Sheet.Name), any of the > following selected sheets throws up a runtime error 5 dialog. But if > I merely use debug.print to print out the info, the loop processes them > all correctly. > > Any suggestions how I can overcome this limitation? I see something > about Sheet.InternalName being consistent across changes, but have > no idea how I would have to cache that info and access it later, or if > that is even the best method? > > TIA, > Bob S. > >
0 Likes
Message 7 of 14

Anonymous
Not applicable
Teun, I probaly am doing that I suppose. I first am basing my for loop on oSelectSet.Count directly (For myItem = 1 To oSelectSet.Count) and then I am assigning objects during each iteration of the loop using Set mySheet = oSelectSet.Item(myItem). It does appear as if the SelectSet is clearing itself, because if I examine the Locals window at the debug point, oSelectSet.Count IS reset to zero. Guess I will look into using collections, GetReferenceKey did not look very easy to use at this point. I thought I might just try pre-assigning another Count variable to use in the loop and see what happens with that, but that resulted in the same behaviour. Are collections part of the Inventor API or just general Visual Basic? Any simple IV based examples anywhere? Bob S. "Teun Ham (IV9)" wrote in message news:4147f4d3$1_2@newsprd01... > Bob, > > Are you directly using/iterating the .SelectSet? > If so, set a watch to the SelectSet.Count and see when it changes (goes to > 0) > > Why? The SelectSet will "clear" itself sometimes if you are iterating it. > If it does, you will have to transfer the items inside the selection in a > collection. > > Cheers, > > Teun > > "Bob S." wrote in message > news:41473194_2@newsprd01... >> I am using preselection to process a select set of drawing sheets, but >> while in the loop, if I change anything (i.e. Sheet.Name), any of the >> following selected sheets throws up a runtime error 5 dialog. But if >> I merely use debug.print to print out the info, the loop processes them >> all correctly. >> >> Any suggestions how I can overcome this limitation? I see something >> about Sheet.InternalName being consistent across changes, but have >> no idea how I would have to cache that info and access it later, or if >> that is even the best method? >> >> TIA, >> Bob S. >> >> > >
0 Likes
Message 8 of 14

Anonymous
Not applicable
OK here's an example: This is something I put together, very handy if I may say. Open an IDW that contains some views of sheetmetal parts (which have a FlatPattern). Select some (or all) views and run this macro. See what happens... Cheers, Teun P.s. It's the "oSelectedObjects As New Collection" that you are interested in, I guess ***** Sub ChangeViewToFlatPatternView() If ThisApplication.Documents.Count = 0 Then MsgBox "A drawing must be active!": Exit Sub If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then MsgBox "A drawing must be active!": Exit Sub Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument If oDrawDoc.SelectSet.Count = 0 Then MsgBox "Please select 1 or more DrawingViews", vbInformation: Exit Sub Dim oSheet As Sheet Set oSheet = oDrawDoc.ActiveSheet Dim oSelectedObjects As New Collection Set oSelectedObjects = Nothing Dim i As Integer For i = 1 To oDrawDoc.SelectSet.Count oSelectedObjects.Add (oDrawDoc.SelectSet.Item(i)) Next i For i = 1 To oSelectedObjects.Count If oSelectedObjects(i).Type = kDrawingViewObject Then Dim oDrawingView As DrawingView Set oDrawingView = oSelectedObjects(i) Dim oModel As Document Set oModel = ThisApplication.Documents.Open(oDrawingView.ReferencedFile.FullFileName, False) If oModel.DocumentType = kPartDocumentObject Then Dim sCurrentDocumentSubType As String sCurrentDocumentSubType = oModel.SubType oModel.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Dim oSheetMetalCompDef As SheetMetalComponentDefinition Set oSheetMetalCompDef = oModel.ComponentDefinition Dim oFlatPattern As FlatPattern Set oFlatPattern = oSheetMetalCompDef.FlatPattern ' Check to see if the flat exists. If Not oFlatPattern Is Nothing Then 'FlatPattern exists, so "switch views" Dim oTG As TransientGeometry Set oTG = ThisApplication.TransientGeometry 'Extract View Location Dim oPoint As Point2d Set oPoint = oTG.CreatePoint2d(oDrawingView.Center.X, oDrawingView.Center.Y) 'Create FlatPattern Option Dim oOptions As NameValueMap Set oOptions = InventorApp.TransientObjects.CreateNameValueMap Call oOptions.Add("SheetMetalFoldedModel", False) Dim oFlatView As DrawingView Set oFlatView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, oDrawingView.Scale, kDefaultViewOrientation, kHiddenLineRemovedDrawingViewStyle, , , , oOptions) Dim Response As Integer Response = MsgBox("Orientation Correct?", vbYesNo) If Response = vbNo Then oFlatView.Delete Set oFlatView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, oDrawingView.Scale, kFlatPivot180ViewOrientation, kHiddenLineRemovedDrawingViewStyle, , , , oOptions) End If oDrawingView.Delete oModel.SubType = sCurrentDocumentSubType Else MsgBox "No Flatpattern exists in this model" End If End If End If Next i Set oSelectedObjects = Nothing End Sub
0 Likes
Message 9 of 14

Anonymous
Not applicable
Teun, Thanks much for the example and quick response. It looks alot simpler than I had imagined. Bob S. P.S. Is there a good reason that some of the variables are declared (Dim) within the loops? Just wondering if I should be doing it that way if it makes any difference. "Teun Ham (IV9)" wrote in message news:4148311f_1@newsprd01... > OK here's an example: > > This is something I put together, very handy if I may say. > Open an IDW that contains some views of sheetmetal parts (which have a > FlatPattern). > Select some (or all) views and run this macro. > > See what happens... > > Cheers, > > Teun > > P.s. It's the "oSelectedObjects As New Collection" that you are interested > in, I guess > > ***** > > Sub ChangeViewToFlatPatternView() > > If ThisApplication.Documents.Count = 0 Then MsgBox "A drawing must be > active!": Exit Sub > If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then MsgBox > "A drawing must be active!": Exit Sub > > Dim oDrawDoc As DrawingDocument > Set oDrawDoc = ThisApplication.ActiveDocument > > If oDrawDoc.SelectSet.Count = 0 Then MsgBox "Please select 1 or more > DrawingViews", vbInformation: Exit Sub > > Dim oSheet As Sheet > Set oSheet = oDrawDoc.ActiveSheet > > Dim oSelectedObjects As New Collection > Set oSelectedObjects = Nothing > Dim i As Integer > For i = 1 To oDrawDoc.SelectSet.Count > oSelectedObjects.Add (oDrawDoc.SelectSet.Item(i)) > Next i > > For i = 1 To oSelectedObjects.Count > If oSelectedObjects(i).Type = kDrawingViewObject Then > Dim oDrawingView As DrawingView > Set oDrawingView = oSelectedObjects(i) > > Dim oModel As Document > Set oModel = > ThisApplication.Documents.Open(oDrawingView.ReferencedFile.FullFileName, > False) > > If oModel.DocumentType = kPartDocumentObject Then > Dim sCurrentDocumentSubType As String > sCurrentDocumentSubType = oModel.SubType > > oModel.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" > > Dim oSheetMetalCompDef As SheetMetalComponentDefinition > Set oSheetMetalCompDef = oModel.ComponentDefinition > > Dim oFlatPattern As FlatPattern > Set oFlatPattern = oSheetMetalCompDef.FlatPattern > > ' Check to see if the flat exists. > If Not oFlatPattern Is Nothing Then > 'FlatPattern exists, so "switch views" > Dim oTG As TransientGeometry > Set oTG = ThisApplication.TransientGeometry > > 'Extract View Location > Dim oPoint As Point2d > Set oPoint = oTG.CreatePoint2d(oDrawingView.Center.X, > oDrawingView.Center.Y) > > 'Create FlatPattern Option > Dim oOptions As NameValueMap > Set oOptions = > InventorApp.TransientObjects.CreateNameValueMap > Call oOptions.Add("SheetMetalFoldedModel", False) > > Dim oFlatView As DrawingView > Set oFlatView = oSheet.DrawingViews.AddBaseView(oModel, > oPoint, oDrawingView.Scale, kDefaultViewOrientation, > kHiddenLineRemovedDrawingViewStyle, , , , oOptions) > > Dim Response As Integer > Response = MsgBox("Orientation Correct?", vbYesNo) > > If Response = vbNo Then > oFlatView.Delete > Set oFlatView = oSheet.DrawingViews.AddBaseView(oModel, > oPoint, oDrawingView.Scale, kFlatPivot180ViewOrientation, > kHiddenLineRemovedDrawingViewStyle, , , , oOptions) > End If > > oDrawingView.Delete > > oModel.SubType = sCurrentDocumentSubType > Else > MsgBox "No Flatpattern exists in this model" > End If > End If > End If > Next i > > Set oSelectedObjects = Nothing > > End Sub > >
0 Likes
Message 10 of 14

Anonymous
Not applicable
No, that doesn't matter at all. I usually declare my variables when I need them. If I have finished the piece of code, I move all the Dims to the top of the code (that's cleaner) B.t.w, what do you think of this macro? "Bob S." wrote in message news:41483345$1_1@newsprd01... > Teun, > > Thanks much for the example and quick response. It looks alot > simpler than I had imagined. > > Bob S. > > P.S. Is there a good reason that some of the variables are declared (Dim) > within the loops? Just wondering if I should be doing it that way if it > makes any difference. > > "Teun Ham (IV9)" wrote in message news:4148311f_1@newsprd01... > > OK here's an example: > > > > This is something I put together, very handy if I may say. > > Open an IDW that contains some views of sheetmetal parts (which have a > > FlatPattern). > > Select some (or all) views and run this macro. > > > > See what happens... > > > > Cheers, > > > > Teun > > > > P.s. It's the "oSelectedObjects As New Collection" that you are interested > > in, I guess > > > > ***** > > > > Sub ChangeViewToFlatPatternView() > > > > If ThisApplication.Documents.Count = 0 Then MsgBox "A drawing must be > > active!": Exit Sub > > If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then MsgBox > > "A drawing must be active!": Exit Sub > > > > Dim oDrawDoc As DrawingDocument > > Set oDrawDoc = ThisApplication.ActiveDocument > > > > If oDrawDoc.SelectSet.Count = 0 Then MsgBox "Please select 1 or more > > DrawingViews", vbInformation: Exit Sub > > > > Dim oSheet As Sheet > > Set oSheet = oDrawDoc.ActiveSheet > > > > Dim oSelectedObjects As New Collection > > Set oSelectedObjects = Nothing > > Dim i As Integer > > For i = 1 To oDrawDoc.SelectSet.Count > > oSelectedObjects.Add (oDrawDoc.SelectSet.Item(i)) > > Next i > > > > For i = 1 To oSelectedObjects.Count > > If oSelectedObjects(i).Type = kDrawingViewObject Then > > Dim oDrawingView As DrawingView > > Set oDrawingView = oSelectedObjects(i) > > > > Dim oModel As Document > > Set oModel = > > ThisApplication.Documents.Open(oDrawingView.ReferencedFile.FullFileName, > > False) > > > > If oModel.DocumentType = kPartDocumentObject Then > > Dim sCurrentDocumentSubType As String > > sCurrentDocumentSubType = oModel.SubType > > > > oModel.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" > > > > Dim oSheetMetalCompDef As SheetMetalComponentDefinition > > Set oSheetMetalCompDef = oModel.ComponentDefinition > > > > Dim oFlatPattern As FlatPattern > > Set oFlatPattern = oSheetMetalCompDef.FlatPattern > > > > ' Check to see if the flat exists. > > If Not oFlatPattern Is Nothing Then > > 'FlatPattern exists, so "switch views" > > Dim oTG As TransientGeometry > > Set oTG = ThisApplication.TransientGeometry > > > > 'Extract View Location > > Dim oPoint As Point2d > > Set oPoint = oTG.CreatePoint2d(oDrawingView.Center.X, > > oDrawingView.Center.Y) > > > > 'Create FlatPattern Option > > Dim oOptions As NameValueMap > > Set oOptions = > > InventorApp.TransientObjects.CreateNameValueMap > > Call oOptions.Add("SheetMetalFoldedModel", False) > > > > Dim oFlatView As DrawingView > > Set oFlatView = oSheet.DrawingViews.AddBaseView(oModel, > > oPoint, oDrawingView.Scale, kDefaultViewOrientation, > > kHiddenLineRemovedDrawingViewStyle, , , , oOptions) > > > > Dim Response As Integer > > Response = MsgBox("Orientation Correct?", vbYesNo) > > > > If Response = vbNo Then > > oFlatView.Delete > > Set oFlatView = oSheet.DrawingViews.AddBaseView(oModel, > > oPoint, oDrawingView.Scale, kFlatPivot180ViewOrientation, > > kHiddenLineRemovedDrawingViewStyle, , , , oOptions) > > End If > > > > oDrawingView.Delete > > > > oModel.SubType = sCurrentDocumentSubType > > Else > > MsgBox "No Flatpattern exists in this model" > > End If > > End If > > End If > > Next i > > > > Set oSelectedObjects = Nothing > > > > End Sub > > > > > >
0 Likes
Message 11 of 14

Anonymous
Not applicable
At first I did not try the macro, I just examined the code for the collection object usage. I put the code in my default.ivb and tried it on a drawing I have which the part has a flatpattern in (the view also already has a view of the flat pattern, among other views) and I am running into an "Object required" error on the line: Set oOptions = InventorApp.TransientObjects.CreateNameValueMap As far as I can determine, InventorApp is not set to anything. I changed InventorApp to ThisApplication and it did run OK. I selected 2 views (Top & Front) and they both changed to the same top view of the flat pattern, even though I selected "No" on the second one when asked if the orientation was OK. But I imagine at this point you are not finished with the macro. I hardly ever work with sheetmetal and flat patterns, but at this point if it is going to change all the selected views to the same flat pattern view, I would question if it really needs to allow selection of more than one view, but again, I realize it is not a finished macro it seems. Otherwise, looks good. Bob S. "Teun Ham (IV9)" wrote in message news:4148340d$1_2@newsprd01... > No, that doesn't matter at all. > > I usually declare my variables when I need them. > If I have finished the piece of code, I move all the Dims to the top of the > code (that's cleaner) > > B.t.w, what do you think of this macro? > > "Bob S." wrote in message > news:41483345$1_1@newsprd01... >> Teun, >> >> Thanks much for the example and quick response. It looks alot >> simpler than I had imagined. >> >> Bob S. >> >> P.S. Is there a good reason that some of the variables are declared (Dim) >> within the loops? Just wondering if I should be doing it that way if it >> makes any difference. >> >> "Teun Ham (IV9)" wrote in > message news:4148311f_1@newsprd01... >> > OK here's an example: >> > >> > This is something I put together, very handy if I may say. >> > Open an IDW that contains some views of sheetmetal parts (which have a >> > FlatPattern). >> > Select some (or all) views and run this macro. >> > >> > See what happens... >> > >> > Cheers, >> > >> > Teun >> > >> > P.s. It's the "oSelectedObjects As New Collection" that you are > interested >> > in, I guess >> > >> > ***** >> > >> > Sub ChangeViewToFlatPatternView() >> > >> > If ThisApplication.Documents.Count = 0 Then MsgBox "A drawing must be >> > active!": Exit Sub >> > If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Then > MsgBox >> > "A drawing must be active!": Exit Sub >> > >> > Dim oDrawDoc As DrawingDocument >> > Set oDrawDoc = ThisApplication.ActiveDocument >> > >> > If oDrawDoc.SelectSet.Count = 0 Then MsgBox "Please select 1 or more >> > DrawingViews", vbInformation: Exit Sub >> > >> > Dim oSheet As Sheet >> > Set oSheet = oDrawDoc.ActiveSheet >> > >> > Dim oSelectedObjects As New Collection >> > Set oSelectedObjects = Nothing >> > Dim i As Integer >> > For i = 1 To oDrawDoc.SelectSet.Count >> > oSelectedObjects.Add (oDrawDoc.SelectSet.Item(i)) >> > Next i >> > >> > For i = 1 To oSelectedObjects.Count >> > If oSelectedObjects(i).Type = kDrawingViewObject Then >> > Dim oDrawingView As DrawingView >> > Set oDrawingView = oSelectedObjects(i) >> > >> > Dim oModel As Document >> > Set oModel = >> > ThisApplication.Documents.Open(oDrawingView.ReferencedFile.FullFileName, >> > False) >> > >> > If oModel.DocumentType = kPartDocumentObject Then >> > Dim sCurrentDocumentSubType As String >> > sCurrentDocumentSubType = oModel.SubType >> > >> > oModel.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" >> > >> > Dim oSheetMetalCompDef As SheetMetalComponentDefinition >> > Set oSheetMetalCompDef = oModel.ComponentDefinition >> > >> > Dim oFlatPattern As FlatPattern >> > Set oFlatPattern = oSheetMetalCompDef.FlatPattern >> > >> > ' Check to see if the flat exists. >> > If Not oFlatPattern Is Nothing Then >> > 'FlatPattern exists, so "switch views" >> > Dim oTG As TransientGeometry >> > Set oTG = ThisApplication.TransientGeometry >> > >> > 'Extract View Location >> > Dim oPoint As Point2d >> > Set oPoint = oTG.CreatePoint2d(oDrawingView.Center.X, >> > oDrawingView.Center.Y) >> > >> > 'Create FlatPattern Option >> > Dim oOptions As NameValueMap >> > Set oOptions = >> > InventorApp.TransientObjects.CreateNameValueMap >> > Call oOptions.Add("SheetMetalFoldedModel", False) >> > >> > Dim oFlatView As DrawingView >> > Set oFlatView = oSheet.DrawingViews.AddBaseView(oModel, >> > oPoint, oDrawingView.Scale, kDefaultViewOrientation, >> > kHiddenLineRemovedDrawingViewStyle, , , , oOptions) >> > >> > Dim Response As Integer >> > Response = MsgBox("Orientation Correct?", vbYesNo) >> > >> > If Response = vbNo Then >> > oFlatView.Delete >> > Set oFlatView = > oSheet.DrawingViews.AddBaseView(oModel, >> > oPoint, oDrawingView.Scale, kFlatPivot180ViewOrientation, >> > kHiddenLineRemovedDrawingViewStyle, , , , oOptions) >> > End If >> > >> > oDrawingView.Delete >> > >> > oModel.SubType = sCurrentDocumentSubType >> > Else >> > MsgBox "No Flatpattern exists in this model" >> > End If >> > End If >> > End If >> > Next i >> > >> > Set oSelectedObjects = Nothing >> > >> > End Sub >> > >> > >> >> > >
0 Likes
Message 12 of 14

Anonymous
Not applicable
Yes, "InventorApp" should have been "ThisApplication" as this code comes from the Addin I am working on. You were also right, I am not quite finished with this macro. The orientation bit needs to be finished. As for the "multi-select": we detail-out several (different) pieces of sheetmetal per sheet (3 or 4). So we first place the views (front view, topview and sometimes the side view), than we change the front view of each part into the flatpattern view.
0 Likes
Message 13 of 14

Anonymous
Not applicable
That would be useful then. "Teun Ham (IV9)" wrote in message > As for the "multi-select": we detail-out several (different) pieces of > sheetmetal per sheet (3 or 4). So we first place the views (front view, > topview and sometimes the side view), than we change the front view of each > part into the flatpattern view. > >
0 Likes
Message 14 of 14

Anonymous
Not applicable
Yes it is 🙂
0 Likes