Accessing Attribute value of a sheet in C#`


I am trying to access the attribute values of a sheet such as the name, format, schematic types etc using C#.

I have tried a lot but cant access them. I created an object for the sheet ids and then tried to iterate through the sheets, and then for every sheet, I tried to access the attributes using another loop. Where I am going wrong?

I also tried using: e3Sheet.GetAttributeValue("Format"), but it wouldn't return the value.

Can someone please help me here?

thanks in advance!



  • Can you post some code?

    Comment actions Permalink
  • Hi Guest500,


    here a small piece of C# code:

    IApplicationInterface e3App;
    IJobInterface e3Job;

    e3App = Activator.CreateInstance(Type.GetTypeFromProgID("CT.Application")) as IApplicationInterface;

    e3Job = e3App.CreateJobObject() as IJobInterface;
    jobId = e3Job.Open(f);
    if (jobId == 0) throw new Exception("Error while opening " + f);

    IDeviceInterface e3Device = null;
    object lstDevices = null;

    int devicesCount = e3Job.GetAllDeviceIds(ref lstDevices);
    for (int deviceIndex = 1; deviceIndex <= devicesCount; deviceIndex++)

    string deviceId = ((Object[])lstDevices)[deviceIndex].ToString();

    string attr_value = e3Device.GetAttributeValue(<attribute name>);



    It's just an example. There are many ways to accomplish this.. And I also did not place the code to free memory, destroy object and so on..

    Let me know if it works.



    Michele Mura

    Comment actions Permalink
  • @Guest500

    "I am trying to access the attribute values of a sheet such as the name, format, schematic types etc using C#."

    These are not attributes of a sheet object. These are properties of the sheet which are accessible via other COM calls. See VBScript posted below.

    If sheet attributes have been applied, then the GetAttributeValue function should work. Whenever I encounter issues with missing attributes, I will often create an adhoc VBScript to see a list of attributes that are on the target. Sometimes problems can occur with incorrect attribute owners or something as simple as a typo.

    If formboard sheets are present in the design, then you need to be aware that in certain situations, the GetActiveSheetId will get the ID of the embedded region which is a child of the sheet. Sheet attributes are not found in the embedded region so you need to get the parent ID and use that to set the sheet object before getting attributes.

    Option Explicit
    Dim e3 : Set e3 = CreateObject("CT.Application")
    Dim job : Set job = e3.CreateJobObject()
    Dim sht : Set sht = job.CreateSheetObject()
    Dim att : Set att = job.CreateAttributeObject()
    Dim j, sheetCount, sids
    sheetCount = job.GetSheetIds(sids)

    e3.PutMessage "There are " & sheetCount & " sheets"
    e3.PutMessage ""
    For j = 1 to sheetCount
    sht.SetId sids(j)
    Dim SheetName : SheetName = sht.GetName()
    Dim SheetFormat : SheetFormat= sht.GetFormat()
    e3.PutMessage "---Sheet Properties ----------------"
    e3.PutMessage Left("Sheet Name" & Space(18),18) & ": " & SheetName
    e3.PutMessage Left("Format" & Space(18),18) & ": " & SheetFormat
    e3.PutMessage Left("IsFormboard" & Space(18),18) & ": " & sht.IsFormboard()
    e3.PutMessage Left("IsEmbedded" & Space(18),18) & ": " & sht.IsEmbedded()
    e3.PutMessage Left("GetParentSheetId" & Space(18),18) & ": " & sht.GetParentSheetId()

    e3.PutMessage ""
    e3.PutMessage "---Sheet Schematic Types -----------"
    Dim k, typeCount, arrTypes
    typeCount = sht.GetSchematicTypes(arrTypes)
    For k = 1 to typeCount
    e3.PutMessage Left(k & ". " & Space(5), 5) & Left("Schematic Type" & Space(25),25) & ": " & arrTypes(k)

    e3.PutMessage ""
    e3.PutMessage "---Sheet Attributes ----------------"
    Dim m, attCount, attIds
    attCount = sht.GetAttributeIds(attIds)
    e3.PutMessage "There are " & attCount & " sheet attributes"
    For m = 1 to attCount
    att.SetId attIds(m)
    e3.PutMessage Left(m & ". " & Space(5), 5) & Left(att.GetName & Space(25), 25) & ": " & att.GetValue

    Set job = Nothing
    Set e3 = Nothing


    Comment actions Permalink
  • Thanks a lot for all your help !

    I was able to solve the problem.


    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post