12 Replies Latest reply on Feb 11, 2014 4:34 PM by Tony Hong

    Add a new revision by c# API

    Tony Hong

      Hi All,

       

      I tried to develop a function to add a new revision using c# API. What I did is getting the latest revision using SolidWorks Document Manager; then try to add a new revision by calling AddRowHead(). But it doesn't work. The code snippets is shown as follow.

       

      Can anyone let me know the solutions? Thanks

       

                swDocMgr = (SwDMApplication3)swClassFact.GetApplication(sLicenseKey);

                swDocument15 = (SwDMDocument15)swDocMgr.GetDocument(filepath, SwDmDocumentType.swDmDocumentDrawing, true, out nRetVal);

       

       

                  if (swDocument15 != null)

                  {

                      String[] vTables = null;

                      vTables = (String[])swDocument15.GetTableNames(SwDmTableType.swDmTableTypeRevision);

       

       

                      SwDMTable3 swTbl;

                      String[] vTabArr;

                      SwDmTableError err;

       

       

                      int row;

                      int col;

       

       

                      string szLastRvNO = "";

                      string szLastRvDate = "";

                      string szLastRvDesigner = "";

                      string szLastRvStatus = "";

       

       

                      if ((vTables != null))

                      {

                          swTbl = (SwDMTable3)swDocument15.GetTable((String)vTables[0]);

       

       

                          if ((swTbl != null))

                          {

                              vTabArr = (String[])swTbl.GetTableCellText(out err, out row, out col);

       

       

                              if (row > 1)

                              {

                                  szLastRvNO = vTabArr[0];

                                  szLastRvDate = vTabArr[1];

                                  szLastRvDesigner = vTabArr[2];

                                  szLastRvStatus = vTabArr[3];

                              }

                              else

                                  szLastRvNO = "0";

       

       

                              List<string> newRv = new List<string>();

                              newRv.Add((Convert.ToUInt16(szLastRvNO) + 1).ToString());

                              newRv.Add(szLastRvDesigner);

                              newRv.Add(szLastRvDate);

                              newRv.Add(szLastRvStatus);

       

       

                              //SwDmTableError tblerr = new SwDmTableError();

                              swTbl.AddRowHead(newRv);

                          }

                      }

                  }

       

                  swDocument15.CloseDoc();