Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy Drawing Views to New Drawing Template

6 REPLIES 6
Reply
Message 1 of 7
johnster100
1618 Views, 6 Replies

Copy Drawing Views to New Drawing Template

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

6 REPLIES 6
Message 2 of 7

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

Message 3 of 7

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

 

Message 4 of 7
Robert..F
in reply to: johnster100

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

 

Message 5 of 7
johnster100
in reply to: johnster100

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

Message 6 of 7
Robert..F
in reply to: johnster100

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

 

 

Message 7 of 7
johnster100
in reply to: Robert..F

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report