Results 1 to 3 of 3

Thread: Convert VB.NET 2013 to 2018,2019,2020

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2018-03
    Posts
    1
    Login to Give a bone
    0

    Default Convert VB.NET 2013 to 2018,2019,2020

    I found a vb.net that should renumber sheet sets

    Code:
    /*
     * © 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 convert this vb.net from 2013 to 2018,2019,2020, but I just can get errors. So, I need your help.

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,544
    Login to Give a bone
    0

    Default Re: Convert VB.NET 2013 to 2018,2019,2020

    What errors???
    C:> ED WORKING....

  3. #3
    All AUGI, all the time marko_ribar's Avatar
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    545
    Login to Give a bone
    0

    Default Re: Convert VB.NET 2013 to 2018,2019,2020

    Quote Originally Posted by jntm226765193 View Post
    I found a vb.net that should renumber sheet sets
    ...I tried convert this vb.net from 2013 to 2018,2019,2020, but I just can get errors. So, I need your help.
    Read @n.yuan comment better...
    http://www.theswamp.org/index.php?to...3780#msg593780
    Marko Ribar, d.i.a. (graduated engineer of architecture)

    M.R. on Youtube


Similar Threads

  1. 2019: Civil 3d 2020
    By rmk in forum AutoCAD Civil 3D - General
    Replies: 9
    Last Post: 2019-07-18, 01:42 AM
  2. 3dsmax 2018 SP4 / 2019.1.1 probleme d'affichage
    By Pierh67 in forum Français - 3ds Max / Maya
    Replies: 5
    Last Post: 2019-05-14, 09:54 AM
  3. Quadro M1200 for Autocad 2018 and Revit 2018
    By fredrik.schlau in forum Hardware
    Replies: 8
    Last Post: 2018-03-19, 09:09 PM
  4. Replies: 0
    Last Post: 2010-11-16, 06:48 PM
  5. AutoCAD .NET (dot net) for beginners
    By Filipe Francisco in forum ATP Course Wishlist
    Replies: 6
    Last Post: 2007-08-16, 11:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •