Attribute update

I'm trying to get an visible attribute to update when I update a device id. Does anyone know how I might do this with either vba, visual basic, or with a SQL Server procedure or trigger?

  • Do you mean automatically update an attribute when the device id is changed? if yes, I guess the value of the attribute must have some relations to the device id. in this case, you can update the database by a trigger, then write a simple plugin(either VBA or VB, whatever you like) to update the drawing from database.

  • Dave,

    Just to add that there is an attribute that can be added to any symbol that will display the device Tag of another symbol: Tag Associate

    This won't help however if the text needs displaying on the same symbol together with some custom text :(

    John.


    This is a test

  • Thanks for the info. What I need specifically is what class I need to use within my plug-in to refresh my drawing after a change is made to the ID and how to capture a command such as (update deviceID or closing the data manager form) to initiate the update.

    Dave

  • Hi Dave,

    It's hard for you to capture the command like you said by promis-e API at the moment, unless you specially develop a program by pure AutoCAD API. I don't think that is worth for your requirement. I think what you can do is to develop a program to forcibly update the symbol attributes according to your rules.

    You can try the following code:

    //get symbol object

    string symHandle = "???";//replace the question marks with the real handle

    ECT.ECAD.API.Symbol sym = ECT.ECAD.API.Root.App.ClassFactory.SymbolFromHandle(ECT.ECAD.API.Root.App.ActiveProject, symHandle, ECT.ECAD.API.Root.App.ActivePage.id);

    ECT.ECAD.API.SymbolAttributes atts = sym.SymbolAttributes;

    atts.DBGet();

    string attName = "";// the name of the attribute you want to update.

    atts[attName].Value = "???";//replace the question marks with the real value you want to update to.

    atts[attName].DBUpdate();//update database

    sym.PaintSymAtt(atts[attName]);//update drawing

    ECT.ECAD.API.Root.App.ActivePage.Save();//make sure this sentence is not missed.

    Chak

  • Dave,

    in order to catch when certain dialogues close, its a bit tricky. there are no events for specific dialogues closing.

    you would need to register with the after form load event and then register the form close for that form (if its the one you are interested in. then when it closes do your work when that event fires.

    eg. for Project Manager (DManager) it might be like this.

    public void Init()

    {

       //catch form load event

       ECT.ECAD.API.Event.EventCenter.AfterFormLoad += new ECT.ECAD.API.Event.CallBack_AfterFormLoad(EventCenter_AfterFormLoad);

    }

    private void EventCenter_AfterFormLoad(Form form)

    {

       if (form is DManager)

       {

           //register closing event

           form.FormClosing += new FormClosingEventHandler(form_FormClosing);

       }

    }

    void form_FormClosing(object sender, FormClosingEventArgs e)

    {

        //unregister form closing event

        Form f = sender as Form;

        f.FormClosing -= form_FormClosing;

        //do your work in here

    }

    also, with attributes, don't just change the database, you need to actively change the drawing element as Chak has said in his post.