I am playing with copying views between drawings and sheets.
@Curtis_Waguespack showed me in this post:
that you can copy section view by copying the whole sheet and deleting what you don't need then deleting the extra sheet. The problem is I don't want to delete that sheet as I will have things on it from another paste and I want to collate the two sheets. How can I copy a section view from sheet 2 to sheet 1? I tried copying the base view first to try keep the connection but it still didn't like it. This is what I tried:
Dim MainDrawing As DrawingDocument = ThisDoc.Document 'Defining document as a drawing Dim MainSheet As Sheet = MainDrawing.Sheets.Item(1) 'Sheet pasting to Dim NewSheet As Sheet = MainDrawing.Sheets.Item(2) 'Sheet copying from NewSheet.DrawingViews.Item(1).CopyTo(MainSheet) 'Base view NewSheet.DrawingViews.Item(2).CopyTo(MainSheet) 'Section view
with the error:
Error on line 5 in rule: collate, in document: GeneratorTemplate.idw
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi @harvey_craig2RCUH. One thing that comes to mind is the fact that these methods are 'copying', not just 'moving' the views. Plus, in this case, it is within the same DrawingDocument. I think that in this case, you will want to be working with the DrawingView.MoveTo method, instead of the DrawingView.CopyTo method. If you are copying them, then the originals will still be on the second sheet when done, which will be confusing for Inventor to keep up with which section view is dependant on which base view, causing the error.
Wesley Crihfield
(Not an Autodesk Employee)
Hi Wesley,
Thanks for pointing that out. I've changed my code and still have the same error.
Harvey
Maybe posting the actual error message contents may help us determine which step along that last line of code it is encountering that error. It says it is an 'argument' related error, which means it does not like one of the 'inputs' you supplied into them. But what we do not know is why, or which 'input' it is happening for (the '2', or the 'MainSheet'). If there was no second view on that sheet, it would be at the '2' input, otherwise it may not want to move that view to that other sheet for some reason. The online help says that this method will throw an error if you try to move the view to its parent sheet, but it looks like you are moving the view from sheet 2 to sheet 1, so that does not seem relevant. Are there only those 2 views on that second sheet, or are there more views. If there are more views, then you may need to specify the views by their names, instead of by their index numbers, just to be sure which ones you are working with.
Wesley Crihfield
(Not an Autodesk Employee)
Try these workflow manually in the browser and I think you will see that we can copy or move the base view, but we can not copy or move the section view, so I think we just can not do this programmatically either.
When I have had a need to do this, I have typically just set up a sheet with all the views I would need, and then copied the sheet, and then deleted or suppressed what I didn't need on a sheet by sheet basis.
Maybe that won't work for you though, in which case I think you will need to generate the views from scratch vs. copying them.
Correction to what I said above. I noticed we can move the section view manually if we do it first, so I checked and this seems to work if we reverse the view order.
Dim MainDrawing As DrawingDocument = ThisDoc.Document 'Defining document as a drawing Dim MainSheet As Sheet = MainDrawing.Sheets.Item(1) 'Sheet pasting to Dim NewSheet As Sheet = MainDrawing.Sheets.Item(2) 'Sheet copying from NewSheet.DrawingViews.Item(2).MoveTo(MainSheet) 'Section view NewSheet.DrawingViews.Item(1).MoveTo(MainSheet) 'Base view
Can't find what you're looking for? Ask the community or share your knowledge.