.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Without open dwg get GETSYSTEMVARIABLE("TDCREATE")?

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
thenndral
1014 Views, 10 Replies

Without open dwg get GETSYSTEMVARIABLE("TDCREATE")?

Hi,

Is it possible to Get Create Date and Time without open drawing using GETSYSTEMVARIABLE("TDCREATE")?
ie. Open drawing in memory and Receive Date and Time.

Give me suggestion.

Thanks,
thenndral

10 REPLIES 10
Message 2 of 11
Ajilal.Vijayan
in reply to: thenndral

Try this .

 

 Dim Side_dbase As Database = New Database(False, True)
 Dim EX As Autodesk.AutoCAD.Runtime.Exception = New Autodesk.AutoCAD.Runtime.Exception
        Try
            Side_dbase.ReadDwgFile("FileName", FileOpenMode.OpenForReadAndWriteNoShare, True, "")

            MsgBox(Side_dbase.Tdcreate)
            Side_dbase.Dispose()
        Catch ex
        End Try

 

Message 3 of 11
thenndral
in reply to: Ajilal.Vijayan

Hi Ajilal.Vijayan,

 

Thanks for your quick reply. Its works like a charm.

 

one more question. Is it possible to get millisecond from TDCREATE or other method?

 

 

I'm using C#, convert it into C#.

Here is the code for C# user[It may be helpful for someone]

 

        [CommandMethod("TTS")]
        public void Time_tracking()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database Side_dbase = new Database(false, true);
            Autodesk.AutoCAD.Runtime.Exception EX = new Autodesk.AutoCAD.Runtime.Exception();
            try
            {
                string blockQualifiedFileName = "D:\\AutoCAD\\testing\\time_chk.dwg";
                Side_dbase.ReadDwgFile(blockQualifiedFileName, FileOpenMode.OpenForReadAndWriteNoShare, true, "");

                AcadApp.ShowAlertDialog("Created:" + Side_dbase.Tdcreate);
                Side_dbase.Dispose();
            }
            catch
            {
            }
}

 

Thanks in advance,

Thenndral.

Message 4 of 11
Ajilal.Vijayan
in reply to: thenndral

Try this

 

 MsgBox(Side_dbase.Tdcreate.ToOADate + 2415018.5)

 

Message 5 of 11
thenndral
in reply to: thenndral

 

Hi,

 

Thanks for your reply.

 

If I use the code. It retrieves Date in double. 

 

AcadApp.ShowAlertDialog("Created :" + tmp_db.Tdcreate.ToOADate() + 2415018.5);

Please check the image file for retrieve result .

 

I convert Julian Date using below code. This code can convert upto seconds.

 

Could you tell me how to make in milliseconds.

 

        private DateTime ConvertAcadJulianToDateTime(double julianDate)
        {
            DateTime date;
            try
            {
                double z = Math.Floor(julianDate);
                double w = Math.Floor((z - 1867216.25) / 36524.25);
                double x = Math.Floor(w / 4);

                double a = (z + 1 + w - x);
                double b = a + 1524;
                double c = Math.Floor((b - 122.1) / 365.25);

                double d = Math.Floor(365.25 * c);
                double e = Math.Floor((b - d) / 30.6001);
                double f = Math.Floor(30.6001 * e);

                int day = Convert.ToInt32(b - d - f);

                int m = Convert.ToInt32((e < 14) ? (e - 2) : (e - 14));
                int month = (m + 1);

                int y = Convert.ToInt32((m > 1) ? (c - 4716) : (c - 4715));
                int year = (y == 0) ? (y - 1) : y;
                //
                // strip the integer
                double t = (julianDate - z);
                // hours since midnight
                double hours = Math.Floor(t * 24.0);
                // temp value
                double mins = t - (hours / 24.0);
                // 1440 minutes per day
                double minutes = Math.Floor(mins * 1440.0);
                //
                double seconds = Math.Floor((mins - (minutes / 1440.0)) * 86400.0);
                //86400000 = 1day
                
                date = new DateTime(year, month, day, Convert.ToInt32(hours), Convert.ToInt32(minutes), Convert.ToInt32(seconds));
                return date;
            }
            catch (ArgumentOutOfRangeException ex)
            {
                AcadApp.ShowAlertDialog("Julian date could not be converted:\n" +  ex.Message);
                date = new DateTime(0);
            }
            catch (Exception ex)
            {
                AcadApp.ShowAlertDialog("Error converting Julian date:\n" + ex.Message);
                date = new DateTime(0);
            }
            return date;
        }

 

Thanks in advance,

thenndral

 

 

Message 6 of 11
Ajilal.Vijayan
in reply to: thenndral

Try with this function

 

jul = tmp_db.Tdcreate.ToOADate() + 2415018.5)

 

  Private Function Getmilsecond(ByVal jul As Double)
        Dim mil As Double

        Dim time As Double = (jul - Math.Floor(jul)) * 86400
        Dim mm As Double = Math.Floor(time / 60)
        mil = time - (mm * 60)
        Return mil
    End Function

 

Message 7 of 11
thenndral
in reply to: Ajilal.Vijayan

Hi,

 

Thanks for your quick reply.

 

In my previous post code I can retrieve seconds from Julian date.

 

 double seconds = Math.Floor((mins - (minutes / 1440.0)) * 86400.0);
                //86400000 = 1day
                
                date = new DateTime(year, month, day, Convert.ToInt32(hours), Convert.ToInt32(minutes), Convert.ToInt32(seconds));

 

 

In this code I'm getting seconds not milliseconds.

jul = tmp_db.Tdcreate.ToOADate() + 2415018.5)

 

private object Getmilsecond(double jul)
{
    double mil = 0;

    double time = (jul - Math.Floor(jul)) * 86400;
    double mm = Math.Floor(time / 60);
    mil = time - (mm * 60);
    return mil;

 

 

I need how to get millisecond from Julian Date.

for more information, Please see the image.

 

Thanks in advance,

thenndral

Message 8 of 11
Ajilal.Vijayan
in reply to: thenndral

Hi,


 That function will return the seconds from julian date with milliseconds

 

See the below results from a test drawing

 

Out from the funtion.

MIL.JPG

 

 

and output of autocad TIME command

MIL2.JPG

 

 

Message 9 of 11
thenndral
in reply to: Ajilal.Vijayan

Hi,

 

Thanks a lot for your quick reply and solution.

I got it.

 

I accept your solution.

 

Thanks again,

thenndral.

Message 10 of 11
Ajilal.Vijayan
in reply to: thenndral


@thenndral wrote:

Hi,

 

Thanks a lot for your quick reply and solution.

I got it.

 

I accept your solution.

 

Thanks again,

thenndral.


Glad to hear that !!

Message 11 of 11
dbrenner
in reply to: thenndral

Can I get a copy of your app? I'd love to be able to quickly check TDCREATE values without having to open the dwgs. Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost