5 Replies Latest reply on Jul 6, 2012 8:24 AM by jeremy_parker

    Adding a part in the library thru automation

    mans.joling

      Hello,

       

      I want to add a new part in the library in a certain partition with some properties.

      I have the partnumber,partname,description and the following properties :

      manufacturer,price,manufacturer partnumber and fitrate values.

      Has someone a piece of code in VB or C# or have a idea to make this happens.

       

      Regards

       

      Mans

        • 1. Re: Adding a part in the library thru automation
          jeremy_parker

          Adding a part is easy, asssociating the symbols, cells, figuring out the pin mapping, no connects and supply pins are the hard part.

           

          Also, there is a bug in automation that doesn't allow a user to add properties to a part, so half your request can't be done today.

           

          To create a part:

           

          'Creates a handle to the Parts Editor in Library Manager

          pedApp = CreateObject("MGCPCBLibraries.PartsEditorDlg")

          pedDoc = pedApp.OpenDatabaseEx("Your Library", False)

           

          Dim pdbPartition As Partition

          Dim pdbPartitions As Partitions = pedDoc.Partitions      'Get the collection of partitions in the parts editor

          For Each pdbPartition In pdbPartitions    'Step through each part partition in the parts editor

           

           

          If pdbPartition.Name = "Your Partition

           

          Dim oPart As MGCPCBPartsEditor.Part

          oPart = pdbPartition.NewPart()

           

          oPart.Number = "Your Part Number"

          oPart.Name = "Your Part Name"

          oPart.Label = "Your Part Label"

          oPart.RefDesPrefix = "Ref Des Prefix"

          oPart.Type = (Set to the appropriate part type)

           

          oPart.Commit()

           

          Exit For

           

          End If

           

          Next

           

          pedApp.CloseActiveDatabase(True)

          pedDoc = Nothing

           

          That should be right...but I may have missed something.

           

          Might I ask what idea you may be pursuing?

          • 2. Re: Adding a part in the library thru automation
            mans.joling

            Hello Jeremy,

             

            Every new part will be created first in Omnify our PLM system.

            There are for every part about 10 properties created.

            Now I must create every property and filling his value by hand thru copy/paste in our library

            That's why I want to automate this

            I hope that the bug soon will be solved

             

            Regards

             

            Mans

            • 3. Re: Adding a part in the library thru automation
              lary.e

              Hi,

               

              We manage to add properties.

              In this example 'TopCell' and 'Attachment' are properties that are defined in the central library.

              here is a snippet of the Perl code:

               

              my $part;

                $part = $partition->NewPart();

                $part->{Number} = "$assigned_part_number";

                $part->Commit();

                return if oleerror();

                $part->{"Label"} = "the label";

                $part->{"Name"} = "the name";

                $part->{"RefDesPrefix"} = "U or whatever";

                $part->{Description} = 'mytest description';

                $part->{TypeString} = 'IC';

                #$part->PutPropertyEx("Type",16,$$pdbconsts{epdbPropTypeString}); #16 is IC

                $part->PutPropertyEx("TopCell","$cell_name",$$pdbconsts{epdbPropTypeString});

                $part->PutPropertyEx("Attachment","xxx.htm",$$pdbconsts{epdbPropTypeString});

              HTH

              • 4. Re: Adding a part in the library thru automation
                mans.joling

                Hello,

                 

                Here is a snippet of code that works

                 

                Public Sub PutPartInfoIntoLmc(ByVal PartsEditorDialog As MGCPCBPartsEditor.IMGCPDBPartsEditorDlg)

                 

                Dim PartsDb As IMGCPDBPartsDB

                 

                Dim Partition As MGCPCBPartsEditor.IMGCPDBPartition

                 

                Dim Partitions As MGCPCBPartsEditor.IMGCPDBPartitions

                 

                Dim newPart As MGCPCBPartsEditor.Part

                 

                Dim RefdesPrefix As String = String.Empty

                 

                Dim PartType As String = String.Empty

                 

                Dim PartNumber As String = String.Empty

                 

                Dim Str As String = String.Empty

                PartsDb = PartsEditorDialog.ActiveDatabaseEx

                Partitions = PartsDb.Partitions

                Partition = PartsDb.ActivePartition

                RefdesPrefix = CmbRefPref.SelectedItem

                PartType = cmbPartType.SelectedItem

                PartNumber = UCase(TxtBLibPartNumber.Text)

                 

                If Len(PartType) >= 2 And Len(RefdesPrefix) >= 1 And Len(UCase(TxtBLibPartNumber.Text)) > 2 Then

                 

                For Each Partition In Partitions

                Str = CmbPartitions.SelectedItem

                 

                If StrComp(Str, Partition.Name) = 0 Then

                newPart = Partition.NewPart()

                newPart.Number = PartNumber

                newPart.Label = UCase(PartLabel)

                newPart.Description = UCase(Description)

                newPart.RefDesPrefix = RefdesPrefix

                newPart.TypeString = PartType

                newPart.Commit()

                newPart.PutPropertyEx(

                "EYEOL", Eyeol, EPDBPropertyType.epdbPropTypeString)

                newPart.PutPropertyEx(

                "ESD CLASS_HBM", HBM, EPDBPropertyType.epdbPropTypeString)

                newPart.PutPropertyEx(

                "ESD_CLASS_MM", MM, EPDBPropertyType.epdbPropTypeString)

                newPart.PutPropertyEx(

                "FIT-L-20EL", FITL20EL, EPDBPropertyType.epdbPropTypeReal)

                newPart.PutPropertyEx(

                "FIT-L-20SS", FITL20SS, EPDBPropertyType.epdbPropTypeReal)

                newPart.PutPropertyEx(

                "FIT-L-80SS", FITL80SS, EPDBPropertyType.epdbPropTypeReal)

                newPart.PutPropertyEx(

                "FIT-L-80EL", FITL80EL, EPDBPropertyType.epdbPropTypeReal)

                newPart.PutPropertyEx(

                "Price", "0.0", EPDBPropertyType.epdbPropTypeReal)

                newPart.PutPropertyEx(

                "MPN", VendorPartNumber, EPDBPropertyType.epdbPropTypeString)

                newPart.PutPropertyEx(

                "Manufacturer", VendorName, EPDBPropertyType.epdbPropTypeString)

                 

                Exit For

                 

                End If

                 

                Next

                 

                End If

                PartsEditorDialog.SaveActiveDatabase()

                PartsDb =

                Nothing

                 

                End Sub

                • 5. Re: Adding a part in the library thru automation
                  jeremy_parker

                  Interseting, if others are able to get properties on their parts now then the bug must have been fixed without me knowing it.

                   

                  I thank everyone for their responses.