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
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.
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
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
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
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
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