Start a new topic

Reading properties from AutoCad DWG by using API


I like to read out an AutoCAD property and want to realize it during AutoCAD API.

I tried to realize it according the following description:


I also update my powershell Version to 5.1. But If I start the Job I always get the following error Messages:

11:14:07: [ FATAL] - Execute failed with exception
11:14:07: [ ERROR] - You cannot call a method on a null-valued expression.

How can I fix this issue?

Thanks for your help!

Hello Martin,

Which property are you trying to read?

Can you please show me the code that you used?

Kind regards,

Manuel Cassan

Hi Manuel,

I try to read out an user defined property.

I used the following code:


Invoke-Script -apartmentState STA -script {
    try {
        $fileName = "Test.dwg"
        $file = Get-VaultFile -Properties @{ "File Name" = $fileName }
        $application = New-Object -ComObject AutoCAD.Application.20 #AutoCAD 2016. For 2015 use: AutoCad.Application.19
        # Open ACAD document    
        #$application.Visible = $true
     } finally {
        if($application.ActiveDocument) {
            $application.ActiveDocument.Close($false) #object.Close([SaveChanges] [, FileName])
        Write-Host "Closed the application."


I have a solution for my Problem:

The Code: "Open-VaultConnection" sould not be insert the Invoke-Script. Now I can open AutoCAD via API!

Do you have an how I can now read out the iproperties?



Hello Martin,

Is there a specific reason why this is done using the API?

The properties can be read using e.g Get-VaultFile. The file object will have the properties.

Kind regards,

Manuel Cassan


Ok, I try to do it in your way.Thanks.

One questions: Can you tell me how I can get the linked Item of a file?

This would be great!


Hello Martin,

You can use the Vault API to get the item linked to a file. First you can get the file using e.g. Get-VaultFile then use the Id to get the item:


Kind regards,

Manuel Cassan

Hi Manuel,

thank you. I could fix my Problem and now my code works. Fine!

I have one last question about reading user definded properties.

A System property I can read out in the follwing way:

$systemproperty_Title=  $file.Title

If I create a user property, the System Name is something like this:


How can I read out this property?

Thank you for helping!


Hi Martin,

The property  can be accessed trough the DispName. 

Kind regards,

Manuel Cassan

1 person likes this
Login or Signup to post a comment