Copy Drawing Views to New Drawing Template

Copy Drawing Views to New Drawing Template

johnster100
Collaborator Collaborator
1,832 Views
6 Replies
Message 1 of 7

Copy Drawing Views to New Drawing Template

johnster100
Collaborator
Collaborator

Hi There,

I've recently made a new drawing template with ilogic prompts for entering data for all fields within the template. It also sets view sizes etc.  

 

I have lots of master drawings, which are reused when sizes etc change for a contract, which i would like to transfer to this new template. Drawing Resource Transfer Wizard does not offer this function.

 

Is there any API code which would do this for me? Ideally I could get all drawings in a folder copied to specific sheet size on the master template.

 

As the template will probably be developed further in the future I'm very loathed to do this take manually.

 

thanks,

John

0 Likes
1,833 Views
6 Replies
Replies (6)
Message 2 of 7

philippe.leefsma
Alumni
Alumni

Hi John,

 

Does "DrawingView.CopyTo" method addresses your query? Please take a look at the API Help Files if you need more details.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 7

johnster100
Collaborator
Collaborator

Hi,

thanks for the reply. This may help, I'm not entirely sure how to use it. Is there any examples anyway? I have code to loop though each view but i don't know how to copy to another sheet in another file

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument

oSheets = oDrawDoc.Sheets

 

For Each oSheet In oSheets   

   oViews = oSheet.DrawingViews   

 

     For Each oView In oViews 

             oView.CopyTo("what goes in here?")

     Next

Next

 

 

thanks,

John

 

0 Likes
Message 4 of 7

Anonymous
Not applicable

It wants a Sheet object like this:

 

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oNewDoc As Inventor.DrawingDocument
Set oNewDoc = ThisApplication.Documents.Open("C:\New Drawing Document.IDW", True)

Dim oSheets As Sheets
Set oSheets = oDrawDoc.Sheets

Dim oViews As DrawingViews
Dim oView As DrawingView
Dim oSheet As Sheet

For Each oSheet In oSheets
   Set oViews = oSheet.DrawingViews
     For Each oView In oViews
             oView.CopyTo oNewDoc.Sheets(1)
     Next
Next

 

0 Likes
Message 5 of 7

johnster100
Collaborator
Collaborator

Thanks Robert,

that works pretty well.

 

Only problem is that if the view has a section view it seems to jump out. Is there a way to copy the view and all views contained within that view? A sort of copy all function?

 

thanks,

John

0 Likes
Message 6 of 7

Anonymous
Not applicable

This doesn't seem to be possible, even through the UI; when I select a section view the copy command is immediately greyed out.  In theory you could create a new sketch and section view in the new drawing then recreate any annotations and dimensions all based off the source drawing, but this would be rather complicated for a relatively simple task. 

 

You could copy the entire sheet to the new template as shown below then replace any titleblocks, borders, etc as required.

oSheet.CopyTo oNewDoc

 

 

0 Likes
Message 7 of 7

johnster100
Collaborator
Collaborator

Hi Guys,

Copying the sheet worked a treat.

 

It would be nice if I could also copy over the iproperties from the original to the new drawing (description, drawing number etc). Is there anyway you can loop through the iproperties and set them?

 

Somethink like this?

 

 

for each iproperty in iproperties 

    try

         newDrawing.Iproperty(Iproperty.Name) = oldDrawing.Iproperty(Iproperty.name)

    catch

         'new drawing does not contain property with this name

    end try

 

next

 

I've had a look through the forum and not came across anything.

 

thanks again,

John

0 Likes