how to get document size from iproperties through API

how to get document size from iproperties through API

liminma8458
Collaborator Collaborator
537 Views
4 Replies
Message 1 of 5

how to get document size from iproperties through API

liminma8458
Collaborator
Collaborator

Hi,

I want to get the size information as in the iproperties of a file (ipt or iam). But I can't find it in object of document.propertysets. How can I get it through Inventor API?

 

I tried generic VB.NET code such as:

Dim myFile As New FileInfo(Part2.FullFileName)
Dim sizeInBytes As Long = myFile.Length

But the resulted file size is a little different from the one in iproperties. a bit puzzle!

 

Anyone can help?

Thank you so much!

 

Capture1.PNG

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Accepted solutions (1)
538 Views
4 Replies
Replies (4)
Message 2 of 5

philip1009
Advisor
Advisor

What does myFile.Length tell you instead of the iproperty file size, maybe it's giving you kilobits instead of kilobytes?  I'm also curious what you need that info for, if you're at liberty to say.

0 Likes
Message 3 of 5

Sergio.D.Suárez
Mentor
Mentor

 

Dim doc = ThisDoc.Document

oSize = FileLen(doc.FullFileName)
MessageBox.Show("Bytes: " & oSize & vbCrLf & _
				"KB: " & oSize / 1000 & vbCrLf & _
				"MB: " & oSize / 1000000 )

Hi, The following is an ilogic rule, try to execute it.
I hope this helps solve your problem. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 4 of 5

liminma8458
Collaborator
Collaborator

Oh, I just realize that the little difference is because I used wrong conversion (it should be 1kb = 1024). The result from the generic VB.NET code should be right. Looks like the VB.NET already simple enough.

 

Our program will create some drawing file (idw) then PDF file automatically. This drawing comes from a shrinkwrap part file. This part is big as tens MB. But I have to save it to disc before I can create a  drawing from it. I have to know the size of the shrinkwrap part so that I can remind designers to delete the part file after the PDF is created. Refer to this thread: https://forums.autodesk.com/t5/inventor-customization/question-on-addbaseview-method/m-p/8803720#M97...

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Message 5 of 5

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Why don't you directly delete the created file?

My.Computer.FileSystem.DeleteFile(full file Name)

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes