Stopping a part from saving, when saving a drawing

Stopping a part from saving, when saving a drawing

liam.dewhurstNMKYG
Contributor Contributor
501 Views
7 Replies
Message 1 of 8

Stopping a part from saving, when saving a drawing

liam.dewhurstNMKYG
Contributor
Contributor

Hi Team,

 

Is there a way to edit the drawing and have it save the drawing but not the part?

 

- When we save a drawing we have an automated pdf export.

- And for saving a part, we also have an automated step export.

 

These both mean that our production files are up to date as we work on them.

However when we are saving a drawing its saving the part as well, and the save time is a bit insane.

I had a look at the save dialogue that popped up, and if you move a view in the drawing, it decides that a user edit has been made to the part. Can I bypass this in the drawing only? Turning off user edit means it doesn't save parts edited while in an assembly.

 

Keen for any solutions....
 Screenshot 2021-05-27 171515.png

0 Likes
Accepted solutions (1)
502 Views
7 Replies
Replies (7)
Message 2 of 8

Ralf_Krieg
Advisor
Advisor

Hello

 

Moving a view in the drawing does not dirty the part. Check if there's anything  event triggered action, that modifies the part. Maybe something with updating iProperties?


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 8

liam.dewhurstNMKYG
Contributor
Contributor

Hey,

I couldn't find anything here on our pdf automation?

'Export current drawing as a multi-sheet PDF
oPath = "S:\Production\Public Folders\PDF\"
oFileName = ThisDoc.FileName(False) 'without extension
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 300
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 3
'oOptions.Value("Custom_End_Sheet") = 7

'get PDF target folder path
'Uncomment the following line to append \PDF onto the end of the current IDW folder location
'oFolder = Left(oPath, InStrRev(oPath, "\")) & "PDF"
oFolder = oPath

'Check for the PDF folder and create it if it does not exist
'If Not System.IO.Directory.Exists(oFolder) Then
    'System.IO.Directory.CreateDirectory(oFolder)
'End If

'Set the PDF target file name
'oDataMedium.FileName = oFolder & "\" & oFileName & " Rev" & oRevNum & ".pdf"
oDataMedium.FileName = oFolder & oFileName & ".pdf"

'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)


MessageBox.Show("PDF saved", "File Save")

 
However we also have a Model REV update.

This is the code that pushes the rev of the drawing back to the part. Is there a way to check whether the rev number is the same first? And then push a change if it's different.

Dim odrawdoc As DrawingDocument
odrawdoc = ThisDrawing.Document
Dim odoc As Document
Try
odoc = ThisDrawing.ModelDocument
odoc.PropertySets.Item("Summary Information").Item("Revision Number").Value = odrawdoc.PropertySets.Item("Summary Information").Item("Revision Number").Value
Catch
End Try

 

0 Likes
Message 4 of 8

bradeneuropeArthur
Mentor
Mentor

Make the drawing update deferred.

Now the part will not be saved!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 8

liam.dewhurstNMKYG
Contributor
Contributor

Hey Brayden,

 

I just ran a check on defer updates (in document settings). I'm not sure this is our winner just yet as we still want the drawing to update with changes if you change the part (i.e if you run this setting, then any cuts/features don't auto pull into the drawing)


To qualify the above - we do want the part to update and be saved if there is an uprev in the drawing.

0 Likes
Message 6 of 8

liam.dewhurstNMKYG
Contributor
Contributor

I'm still trying to get an if statement going....

I could pull the drawing rev number & the part rev number.
Then can run a if statement gateway comparing the rev numbers, so that the code only runs if they're different.


Does anyone know how to pull the rev of a part while in a drawing even if the parts not open? I've been hunting through forums but have struck out so far.

Dim odrawdoc As DrawingDocument
Dim odoc As Document
odrawdoc = ThisDrawing.Document
odoc = ThisDrawing.ModelDocument

' part rev number iproperty as value - note: this doesn't pull the part rev number yet!)
odocvalue = odoc.PropertySets.Item("Revision Number").Value

' drawing rev number iproperty as value - note: this works)
odrawdocvalue = iProperties.Value("Summary", "Revision Number")

If (odocvalue <> odrawdocvalue) Then
	Try
	odoc.PropertySets.Item("Summary Information").Item("Revision Number").Value = odrawdoc.PropertySets.Item("Summary Information").Item("Revision Number").Value
	Catch
	End Try
End If

 

0 Likes
Message 7 of 8

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

If you have the drawing open and not "Defer updates" activated, the referenced document is also opened in background. Otherwise Inventor would not be able to update your drawing views.

Your code is missing the PropertySet name in the model document. I would always use internal names for this, cause they are localization independent and will surely never change.

 

 

Dim odrawdoc As DrawingDocument
Dim odoc As Document
odrawdoc = ThisDrawing.Document
odoc = ThisDrawing.ModelDocument

' part rev number iproperty as value - note: this doesn't pull the part rev number yet!)
odocvalue = odoc.PropertySets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").Item("Revision Number").Value


' drawing rev number iproperty as value - note: this works)
odrawdocvalue = iProperties.Value("Summary", "Revision Number")

If (odocvalue <> odrawdocvalue) Then
    Try
    odoc.PropertySets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").Item("Revision Number").Value = odrawdoc.PropertySets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").Item("Revision Number").Value
    Catch
    End Try
End If

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 8 of 8

liam.dewhurstNMKYG
Contributor
Contributor

This checks out - thanks!

I also managed to get the original working through more help.

 

Dim odrawdoc As DrawingDocument
Dim odoc As Document
odrawdoc = ThisDrawing.Document
odoc = ThisDrawing.ModelDocument

If odoc.PropertySets.Item("Summary Information").Item("Revision Number").Value <> odrawdoc.PropertySets.Item("Summary Information").Item("Revision Number").Value Then
odoc.PropertySets.Item("Summary Information").Item("Revision Number").Value = odrawdoc.PropertySets.Item("Summary Information").Item("Revision Number").Value
End If

 

0 Likes