4 Replies Latest reply on May 14, 2012 2:27 AM by Dennis_K

    "AddAttribute" usage in DxDesigner


      Hello at all,


      I'm quite unexperienced with vbs scripting. But with the help of all those examples out there (thanks to all who offer such stuff freely) I was able to write scripts which fit my needs well.

      But now I have an issue with non-common properties from older DxD versions in my projects. Therefore I have to readd the property "Assembled" with its value by using the "addAttribute" Method:


      For Each objCompAttr in objComp.Attributes

           If objCompAttr.name = "Assembled" THEN


                sCompAttrNameValue = objCompAttr.Name & "=" & objCompAttr.Value

                sCompAttrVisible = objCompAttr.Visible

                Set sCompAttrLoc = objCompAttr.GetLocation()


                Set oComp = objComp.AddAttribute(sCompAttrNameValue, sCompAttrLoc.X, sCompAttrLoc.Y, sCompAttrVisible)


      First I looked in the automation help and tried it this way: objComp.AddAttribute(sCompAttrNameValue, sCompAttrLoc.X, sCompAttrLoc.Y, sCompAttrVisible) but I always get an error message After some research I found the line above with the "Set oComp = ..." line. I don't understand why I had to do this. Why not just call the method? What is the sense of the "Set oComp=..." expression in this case? Does the name oComp matter or can I also use "Set XYZ=..."?

      It drives me mad when I do something but don't know why so please can you point me in the right direction...


      Thanks, kind regards,


        • 1. Re: "AddAttribute" usage in DxDesigner

          Hi Dennis,


          What is the error message you are getting?


          If your script starts with 'Option Explicit' then you will need to declare each variable before it is used.


          If that is the issue, then just add a Dim oComp statement before Set oComp = ...



          • 2. Re: "AddAttribute" usage in DxDesigner

            Hi John,


            thanks for your fast response.

            The error message I get is similar to (sorry, this is my own bad translation because I get a german error message):

                 Error 0x800a0414 'no brackets are allowed when calling a subroutine (Sub)'

                 objComp.AddAttribute(sCompAttrNameValue, sCompAttrLoc.X, sCompAttrLoc.Y, sCompAttrVisible)


            I don't use 'Option Explicit' in my scripts so this should not be the issue.



            Kind reagrds,


            • 3. Re: "AddAttribute" usage in DxDesigner



              may be I am not good enough in programming to understand the secret,

              but how do you get the

              sCompAttrLoc.X and sCompAttrLoc.Y


              Set oComp = objComp.AddAttribute(sCompAttrNameValue, sCompAttrLoc.X, sCompAttrLoc.Y, sCompAttrVisible)

              when you do a delete



              Doesn't desotry this the

              objCompAttr Location Parameters?


              Did you ever tested whether

              sCompAttrLoc.X and sCompAttrLoc.Y

              still have valid entries/state at this time?


              Kind regards,


              • 4. Re: "AddAttribute" usage in DxDesigner

                Hi Andreas,


                thanks for your reply.

                I think the location is not the problem the script encounters. As you can see in my first posting I get the location by "Set sCompAttrLoc = objCompAttr.GetLocation()". After deleting the property I us "sCompAttrLoc.X" and "sCompAttrLoc.Y" to get the coordinates back.

                This works correct and without error when I use "Set oComp = objComp.AddAttribute(sCompAttrNameValue, sCompAttrLoc.X, sCompAttrLoc.Y, sCompAttrVisible)" but not when I only use "objComp.AddAttribute(sCompAttrNameValue, sCompAttrLoc.X, sCompAttrLoc.Y, sCompAttrVisible)" And this is the point I don't understand...