Ankündigung

Einklappen
Keine Ankündigung bisher.

Rename ALL elements(huge amount) by adding projectcode ending

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Rename ALL elements(huge amount) by adding projectcode ending

    Hello guys!

    How can we quickly re-name huge amount of elements in PDMS, maybe using C#? Or maybe there is some secret way?
    I have 141 Dbs in my project.

    I collect all elements and run cycle through all array elements but
    it takes quite long time to perform this operation.

    PHP-Code:
    var !all coll all with (isnamed)
    do !
    allVal values !all
    !allVal.dbref().name = !allVal.dbref().name '_ending'
    enddo 
    Zuletzt geändert von me_hungry; 13.02.2017, 09:54.
    uTube https://www.youtube....H9a37hEKcuOPDLA
    Blog http://mehungry.uphero.com/

  • #2
    I doesn't have a better solution.
    But at the moment you are converting STRING to DBREF twice.
    Maybe this is faster:
    Code:
    do !ele value !elements
    !dbele = !ele.dbref()
    !dbele.Name = !dbele.Name + '_ending'
    enddo
    PML is interpreted line by line, now it's one more line... :S
    Geht net, gibt's net!
    [Entfessler Start]
    Ois wos I do verzapf, is mei eigana Bledsinn und spieglt net die Meinung der Bude wo I hakl (g'haklt hob oder hakl'n werd) wida.
    [Entfessler Ende]

    Kommentar


    • #3
      Thanks, aequitas - you are correct !

      Also I tried this code:
      PHP-Code:
      VAR !allElelents COLLECT ALL FROM TABLE NAME PREFIX '/'  
      do !allElelent value !allElelents
       
      !allElelent = !allElelent.dbref()
       !
      allElelent.Name = !allElelent.Name '_ending'
      enddo 
      Still waiting but using table name much faster..
      Zuletzt geändert von me_hungry; 13.02.2017, 13:49.
      uTube https://www.youtube....H9a37hEKcuOPDLA
      Blog http://mehungry.uphero.com/

      Kommentar


      • #4
        You can use Report Designer for C# script:
        Create a Report e.g.: Source "WORLD", 1 Attr.: "NAME".
        Report Attached is created with E3D1.1

        Code:
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]using[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Aveva.Pdms.Database;[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]using[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Aveva.Pdms.Utilities.Messaging;[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]using[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Aveva.PDMS.Database.Filters;[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]using[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Aveva.Pdms.Geometry;[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]using[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] System.Windows.Forms;[/SIZE][/FONT][/SIZE][/FONT]
        
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] renameTest_AfterPrint([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]object[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] sender, System.EventArgs e)[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]{[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]  string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] message = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#e47c02][FONT=Courier New][SIZE=2][COLOR=#e47c02][FONT=Courier New][SIZE=2][COLOR=#e47c02]"Rename all Elements?"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]  string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] caption = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#e47c02][FONT=Courier New][SIZE=2][COLOR=#e47c02][FONT=Courier New][SIZE=2][COLOR=#e47c02]"Report Designer Addin"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  MessageBoxButtons buttons = MessageBoxButtons.YesNo;[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  DialogResult result;[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][COLOR=#3f8830][FONT=Courier New][SIZE=2][COLOR=#3f8830][FONT=Courier New][SIZE=2][COLOR=#3f8830] 
          // Displays the MessageBox.[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  result = MessageBox.Show(message, caption, buttons);[/SIZE][/FONT][/SIZE][/FONT]
        
        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]  if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (result == System.Windows.Forms.DialogResult.Yes)[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  {[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]    DbElement world = MDB.CurrentMDB.GetFirstWorld(DbType.Design);[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]    [FONT=Courier New][SIZE=2]DBElementCollection collection = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]new[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] DBElementCollection(world);[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]    [FONT=Courier New][SIZE=2]DbAttribute namatt = DbAttributeInstance.NAME;[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]    [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]foreach[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (DbElement ele [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]in[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] collection)[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]    [FONT=Courier New][SIZE=2]{[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]     [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]try[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]{[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]         [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] name = [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#e47c02][FONT=Courier New][SIZE=2][COLOR=#e47c02][FONT=Courier New][SIZE=2][COLOR=#e47c02]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]        [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] ( ele.GetValidAsString(namatt, [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]ref[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] name) )[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]{[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]           [FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5][FONT=Courier New][SIZE=2][COLOR=#1b49a5]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] newname = name + [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#e47c02][FONT=Courier New][SIZE=2][COLOR=#e47c02][FONT=Courier New][SIZE=2][COLOR=#e47c02]"_ending"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]           [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]ele.SetAttribute(namatt, newname);[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]}[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2]   [/SIZE][/FONT]    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]}[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]     catch {}[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]   }[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  }[/SIZE][/FONT][/SIZE][/FONT]
        [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]}[/SIZE][/FONT][/SIZE][/FONT]
        result.PNGrd-layout.PNGrd-bind-script.PNG
        Angehängte Dateien
        Geht net, gibt's net!
        [Entfessler Start]
        Ois wos I do verzapf, is mei eigana Bledsinn und spieglt net die Meinung der Bude wo I hakl (g'haklt hob oder hakl'n werd) wida.
        [Entfessler Ende]

        Kommentar


        • #5
          Thanks, for your example!!
          Haha))
          Now its new ERA - of BIG DATA, so
          Report Designer will be our new instrument
          I run this report.. will wait - its about 2 200 000 elements that need to be renamed only in Paragon...
          uTube https://www.youtube....H9a37hEKcuOPDLA
          Blog http://mehungry.uphero.com/

          Kommentar


          • #6
            It took app. 2-3 minutes in Design with RD for app. 700.000 elements.
            But this was "local" on my laptop...
            Zuletzt geändert von aequitas; 13.02.2017, 17:03.
            Geht net, gibt's net!
            [Entfessler Start]
            Ois wos I do verzapf, is mei eigana Bledsinn und spieglt net die Meinung der Bude wo I hakl (g'haklt hob oder hakl'n werd) wida.
            [Entfessler Ende]

            Kommentar


            • #7
              I found the reason, why it took so long to rename 4 000 000 elements.
              Because some of them was locked or have long names or same names and it handles many errors.
              I took into account that errors and I spent 26 minutes to rename 4 000 000 using your script.
              Thanks a lot for assistance!
              Zuletzt geändert von me_hungry; 15.02.2017, 11:28.
              uTube https://www.youtube....H9a37hEKcuOPDLA
              Blog http://mehungry.uphero.com/

              Kommentar

              Lädt...
              X