Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Old for new dwg

JamieSENG
Advocate

Old for new dwg

JamieSENG
Advocate
Advocate
I need to swap some old drawing over to our new drawing template. I’ve set up the new dwg template to pull the model data. It has some illogic in it so “drawing export wizard” doesn’t work as I’d want it to.

What I’m doing manually is selecting the views from the page on the original (has copy and paste of browser doesn’t copy section views etc) and then pasting onto the new template, copying the file name, closing original and saving the new file overwriting original.

My idea would be to have a number of drawings open so I assume the code would physically need to move to next drawing before running the code.

Any suggestion?
0 Likes
Reply
282 Views
1 Reply
Reply (1)

JamieSENG
Advocate
Advocate

I'll elaborate a little more on where I am with this issue.

 

I have x number of drawings open and I Arrange them. And on each drawing, I run the rule, minimize the resulted drawing from the rule, close the original and move to the next. Until I'm left with only the resulting drawings at which point I save and overwrite the original.

 

Part of my issue before even considering code that would go through all the open drawings is I can only do it based on a "view 1" so its use as only been for flat pattern drawings with a single view. I'm not sure how I need to modify the code to take all views/elements and not a specific view.

 

Essentially I want to copy all created element on my sheet to my new drawing.

 

The idea of saving over the original file was so its history was kept in the vault.

 

Dim oSrcDwg As DrawingDocument
oSrcDwg = ThisApplication.ActiveDocument
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:\Temp\DWG. Template.dwg", True)


Dim oView As DrawingView
If oSrcDwg.ActiveSheet.DrawingViews.Count < 1 Then
MsgBox ("No views found in the source drawing !")
Return
End If
oView = oSrcDwg.ActiveSheet.DrawingViews(1)

Dim oSheet As Sheet
For Each oSheet In oDrawingDoc.Sheets
oSheet.Activate
Call oView.CopyTo(oSheet)
Exit For
Next
Call oSrcDwg.Save 
'Call oSrcDwg.Close(True)

The commented out part at the end to close the original file caused "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"

 

However, it does close and allow me to move on but I don't really want to be risking crashing out or corrupting the file.

 

So moving on from the above the next step id be looking at would be how I could have this rule run through my open dwg's. I use the below code as part of a batch export which exports x number of open files all in a single press. I assume its something totally different but in theory, it's working without moving to the next drawing. Obviously, what am now trying to achieve you would assume id need to move to the next drawing before the rule ran again. I'm thinking an addin maybe that recognised the number of open document and somehow linked to my rule whereby it ran the rule and then the keyboard command "ctrl+tab" moved to the next, running the rule again until it's gone over the originally opened drawing. The first thing that comes to mind is how does it stop as the original amount of drawings will still be present only having been replaced with the new templates.

 

'Go through each view and save if it's a drawing document
For Each view As View In ThisApplication.Views

 

0 Likes