Jump to content

Convert VB.NET 2013 to 2018,2019,2020


Recommended Posts

Posted

I found a vb.net that should renumber sheet sets
 

 

/*
 * © Andrey Bushman, 2013
 * AutoCAD 2014 x64 Enu
 * 
 * AutoCAD references:
 *
 * AcCoreMgd.dll
 * AcDbMgd.dll
 * AcMgd.dll
 * Interop.ACSMCOMPONENTS19Lib.dll
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
using cad = Autodesk.AutoCAD.ApplicationServices.Application;
using App = Autodesk.AutoCAD.ApplicationServices;
using Db = Autodesk.AutoCAD.DatabaseServices;
using Ed = Autodesk.AutoCAD.EditorInput;
using Rtm = Autodesk.AutoCAD.Runtime;
using Comp = ACSMCOMPONENTS19Lib;
 
[assembly: Rtm.CommandClass(typeof(Bushman.AutoCAD.SheetSetEditor.Commands))]
 
namespace Bushman.AutoCAD.SheetSetEditor {
 
    public class Commands {
 
        const String ns = "bush"; // namespace
 
        [Rtm.CommandMethod(ns, "test", Rtm.CommandFlags.Modal)]
        public void Renumber() {
            App.Document doc = cad.DocumentManager.MdiActiveDocument;
            Db.Database db = doc.Database;
            Ed.Editor ed = doc.Editor;
            Comp.AcSmSheetSetMgr mng = new Comp.AcSmSheetSetMgr();
            Comp.IAcSmEnumDatabase enumerator = mng.GetDatabaseEnumerator();
            Comp.AcSmDatabase smDb = null;
            while ((smDb = enumerator.Next()) != null) {
                String fname = smDb.GetFileName();
                Comp.AcSmSheetSet sheetset = smDb.GetSheetSet();
                String name = sheetset.GetName();
                String descr = sheetset.GetDesc();
                ed.WriteMessage("\nSheet Set: {0}\n", name);
                Comp.IAcSmEnumComponent encomp = sheetset.GetSheetEnumerator();
                Comp.IAcSmComponent component = null;
                while ((component = encomp.Next()) != null) {
                    ProcessElement(ed, component, 0);
                }
                encomp.Reset();
            }
            enumerator.Reset();
        }
 
        // Recursive processing of the elements
        void ProcessElement(Ed.Editor ed, Comp.IAcSmComponent component, Int32 level) {
            ed.WriteMessage("\t{0}{1} (Subset)\n", new String('\t', level), component.GetName());
            Array array = null;
            component.GetDirectlyOwnedObjects(out array);
            if (array != null) {
                Int32 sheet_number = 0;
                foreach (var item in array) {
                    if (item is Comp.IAcSmSubset) {
                        ProcessElement(ed, (Comp.IAcSmSubset)item, level + 1);
                    }
                    else if (item is Comp.IAcSmSheet) {
                        Comp.IAcSmSheet sheet = (Comp.IAcSmSheet)item;
                        ed.WriteMessage("\t\t{0}{1} (Sheet)", new String('\t', level), sheet.GetName());
                        sheet.SetNumber(sheet_number.ToString()); // I get an exception here!
                        ++sheet_number;
                    }
                    else if (item is Comp.IAcSmPersist) {
                        Comp.IAcSmPersist persist = (Comp.IAcSmPersist)item;
                        ed.WriteMessage("\t\t{0}Additional info: {1}", new String('\t', level), persist.GetTypeName());
                    }
                    else {
                        ed.WriteMessage("\t\t{0}Unknown object: {1}", new String('\t', level), item.GetType().ToString());
                    }
                    ed.WriteMessage("\n");
                }
            }
        }
    }
}

 

 

 

...I tried converting this vb.net from 2013 to 2018,2019,2020, but I just can get errors. So, I need your help.
 

 

 

 

 

 

Posted

If you don't know how to use SSM, then why are you using it?
What exactly do you want to do?
Open your file, select the desired title block and enter the number - it's easy.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...