AutoCAD

eInvalidLayer when setting LayerTableRecord.IsFrozen to false

English

Found this problem this morning: if you set IsFrozen to false on the current layer, you'll get an Autodesk.AutoCAD.Runtime.Exception with the ErrorStatus at eInvalidLayer. The setter is certainly checking if the layer is current to avoid freezing it, but it should test the value to ignore when it is false.

So you have to check the layer state before changing the property to false:

Etiquettes:

AutoCAD indexed colors list

English

A little bit of code to export the list of Red, Green and Blue values for indexed AutoCAD colors:

[CommandMethod("DUMPCOLORS")]
public void DumpColors()
{
    using (var sw = new StreamWriter(@"C:\temp\acadColors.txt"))
    {
        sw.WriteLine(" I ; R ; G ; B ");
        for (short colorIndex = 1; colorIndex <= 255; colorIndex++)
        {
            using (Color color = Color.FromColorIndex(ColorMethod.ByAci, colorIndex))
            {
                sw.WriteLine("{0,3};{1,3};{2,3};{3,3}", colorIndex,
                    color.ColorValue.R, color.ColorValue.G, color.ColorValue.B);
            }
        }
    }
}

Etiquettes:

SP1 for AutoCAD 2013 suspended

English

As I told you previously, the first update for AutoCAD 2013 is out, but it was removed because it leads to fatal errors. A new version should be available again soon.

Etiquettes:

SP1 for AutoCAD 2013

English

Service Pack 1 for AutoCAD 2013 is out. This update brings many bugfixes and new features that allow you to block AutoLISP program execution. Indeed, as I explained in this article, it is possible to write a virus using AutoCAD as a vector for the infection.

You can have a detailed description of these features on the blog Whithout a Net

Etiquettes:

Bring an entity to the foreground with VBA

English

VBA does not provide functions to change the draw order of an entity. However, we can use SendCommand for executing DRAWORDER:

Etiquettes:

Get the name of the active AutoCAD document with .NET

English

Here's a little sample code to detect if AutoCAD is running. If it does, it displays the full path of the active drawing.

The code use COM (out of process).

VB.NET

Imports System.Runtime.InteropServices

Module Module1

    Sub Main()
        Try
            Dim acad = Marshal.GetActiveObject("AutoCAD.Application")
            Dim activeDocument = acad.ActiveDocument
            MsgBox("Le chemin complet du document actif est : " & activeDocument.FullName)
        Catch ex As COMException
            Const MK_E_UNAVAILABLE As Integer = &H800401E3
            If ex.ErrorCode = MK_E_UNAVAILABLE Then
                MsgBox("AutoCAD n'est pas en cours d'exécution.")
            Else
                Throw
            End If
        End Try
    End Sub

End Module

Change the draw order of an entity with VBA

English

VBA does not provide functions to change the draw order of an entity. However, we can use SendCommand to run the command _DRAWORDER:

Etiquettes:

A virus targeting AutoCAD

English

The virus Flame is a lot of attention right now. A striking feature here is that it specifically targets AutoCAD DWG files. This suggests that this complex malware was designed by a state eager to seize some secrets documented through drawings.

Subscribe to RSS - AutoCAD