How to Get iProperties in Tab "General" - File NOT Saved

How to Get iProperties in Tab "General" - File NOT Saved

ngdnam88
Advocate Advocate
669 Views
7 Replies
Message 1 of 8

How to Get iProperties in Tab "General" - File NOT Saved

ngdnam88
Advocate
Advocate

Dears,

Could you please help me this point. I wanna check this information in Tab "General"/iProperties. Is it possible to do it?

ngnam1988_0-1722480474529.png

ngnam1988_2-1722480926342.png

 

Or any way can check extension (in this case are .idw vs .dwg) before do something next.
Thanks,

0 Likes
Accepted solutions (3)
670 Views
7 Replies
Replies (7)
Message 2 of 8

m_baczewski
Advocate
Advocate

Hello,

In my opinion, to check if a file is saved or unsaved, it is enough to check the path of the document. If the path is empty, it means that the document has not been saved yet.  There are several ways to obtain the file path. One of them looks like.

 

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oDocPath As String = oDoc.FullFileName

If oDocPath = String.Empty
	MessageBox.Show("Your file has not been saved","Warning",MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
	MessageBox.Show("You can continue your task","Information",MessageBoxButtons.OK, MessageBoxIcon.Information)
End If 

 

0 Likes
Message 3 of 8

ngdnam88
Advocate
Advocate

Hi @m_baczewski 
Thank but I mean I wanna to check the ext. file information in case file still NOT saved because if file saved it'll be easy to check ext. file.

0 Likes
Message 4 of 8

m_baczewski
Advocate
Advocate
Accepted solution

In the drawing, you can check something like DrawingDocument.IsInventorDWG to determine if the drawing is an .idw or a DWG. Take a look and let me know if I understand you correctly.

 

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oDocPath As String = oDoc.FullFileName

If oDoc.SubType = "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}"
	
	Dim oDDoc As DrawingDocument = oDoc
	Dim isInventroDwg As Boolean = oDDoc.IsInventorDWG
	
	If isInventroDwg = True
		MessageBox.Show("This is a DWG files.","Information",MessageBoxButtons.OK, MessageBoxIcon.Information)
	Else
		MessageBox.Show("This isnt a DWG files.","Information",MessageBoxButtons.OK, MessageBoxIcon.Information)
	End If
	
End If
If oDocPath = String.Empty
	MessageBox.Show("Your file has not been saved","Warning",MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
	MessageBox.Show("You can continue your task","Information",MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Message 5 of 8

Michael.Navara
Advisor
Advisor
Accepted solution

Information asked can be obtained from document properties. DocumentType, DocumentSubType. Or in case of drawing from IsInventorDWG.

 

Check file extension before the file is saved is not possible, because it can be changed.

 

@m_baczewski Check property oDoc.FullFileName has limitation because until the file was saved first, this property is Read/Write. You can get non-empty oDoc.FullFileName and the file is not saved. Better solution is to check Document.FileSaveCounter Property is 0 (zero)

Message 6 of 8

m_baczewski
Advocate
Advocate
Thanks for your tip 😉
0 Likes
Message 7 of 8

_dscholtes_
Advocate
Advocate
Accepted solution

I opened a dwg and idw file to check if their document.type or document.subtype were different, but instead I found the following:

'Set reference
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument

'Check type
If oDoc.IsInventorDWG = True Then
    'This is a dwg file
Else
    'This is an idw file
End If

 

Oh, to check whether a file has been saved, you can use:

'Check if the document has been saved
If oDoc.FileSaveCounter = 0 Then
    'Document not saved
Else
    'Document has been saved
End If

 

Message 8 of 8

ngdnam88
Advocate
Advocate

Thanks all of you!
I got it!

0 Likes