Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I need a list of SELECTED layout tab names....

11 REPLIES 11
Reply
Message 1 of 12
JoistDetailer
2872 Views, 11 Replies

I need a list of SELECTED layout tab names....

I need to be able to update the titleblocks for SELECTED layouts only - similar to "publishing" selected tabs.  I'm using Lisp.

 

I'd rather not make a dialog box from the "layoutlist" - it would be easier to select the tabs, then push a button.

 

Thanks.....

11 REPLIES 11
Message 2 of 12
Lee_Mac
in reply to: JoistDetailer

To my knowledge, this is not possible in LISP.

 

The only way I am aware of to retrieve this information is to use the getTabSelected() function of ObjectArx.

Message 3 of 12
BlackBox_
in reply to: Lee_Mac

FWIW -

 

I too know of no way of doing this from LISP natively, however, the .NET API exposes the bool Layout.TabSelected Property, which could be utilized to extend LISP via custom LispFunction Method.

 

As a quick example, consider this pseudo-named, custom LayoutListSelected function:

 

adsk.layoutlistselected.01.png

 

adsk.layoutlistselected.02.png

 

adsk.layoutlistselected.03.png

 

 

 

Attached to this post is an Autoloader .bundle which supports 2012-2014 natively, but the ./Contents/Windows/2010/ assembly can be NETLOADed into 2010 & 2011 as well, as it has been compiled to .NET 3.5 framework (for those still using pre-Autoloader 2010 Database versions)... Simply download, unblock, and unzip to ..\ApplicationPlugins\, and start AutoCAD.

 

[Edit] - Autodesk forums would not allow me to upload the attached Autoloader .bundle as a .ZIP, so I've added a .TXT file extension, which seems to have worked... Simply remove this prior to unzipping.

 

 

 

... And for those, like me, that would prefer to compile themselves, here's the source code (C#):

 

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;

using System.Collections.Generic;

[assembly: CommandClass(typeof(BlackBox.AutoCAD.LayoutListSelected.Commands))]

namespace BlackBox.AutoCAD.LayoutListSelected
{
    class Commands
    {
        [LispFunction("LayoutListSelected")]
        public ResultBuffer LayoutListSelected(ResultBuffer args)
        {
            if (args != null)
                throw new TooManyArgsException();

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            //Editor ed = doc.Editor;
            //LayoutManager layoutMgr = LayoutManager.Current;
            List<string> layouts = new List<string>();
            ResultBuffer res = new ResultBuffer();

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                DBDictionary layoutDic =
                    (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead, false);

                foreach (DBDictionaryEntry entry in layoutDic)
                {
                    Layout layout =
                        (Layout)tr.GetObject(entry.Value, OpenMode.ForRead);

                    string layoutName = layout.LayoutName;

                    if (layout.TabSelected)
                        layouts.Add(layoutName);
                }

                tr.Commit();
            }

            layouts.Remove("Model");

            if (0 < layouts.Count)
            {
                layouts.Sort();

                foreach (string layoutName in layouts)
                {
                    res.Add(new TypedValue(5005, layoutName));
                }

                return res;
            }

            else
                return null;
        }
    }

    // Special thanks to Gile for his LispException classes:
    class LispException : System.Exception
    {
        public LispException(string msg) : base(msg) { }
    }

     class TooFewArgsException : LispException
     {
        public TooFewArgsException() : base("too few arguments") { }
     }

     class TooManyArgsException : LispException
    {
        public TooManyArgsException() : base("too many arguments") { }
     }

     class ArgumentTypeException : LispException
     {
         public ArgumentTypeException(string s, TypedValue tv)
             : base(string.Format(
            "invalid argument type: {0}: {1}",
            s, tv.TypeCode == (int)LispDataType.Nil ? "nil" : tv.Value))
        { }
     }
}

 



"How we think determines what we do, and what we do determines what we get."

Message 4 of 12
JoistDetailer
in reply to: BlackBox_

That looks like it will work. I appreciate your response and effort!

However, you lost me when you said to "download, unblock, and unzip to .." - what do you mean by "unblock"?? Please pardon my ignorance...I'm not familiar with the Autoloader or dotNet.
Message 5 of 12
BlackBox_
in reply to: JoistDetailer


@JoistDetailer wrote:
That looks like it will work. I appreciate your response and effort!

However, you lost me when you said to "download, unblock, and unzip to .." - what do you mean by "unblock"?? Please pardon my ignorance...I'm not familiar with the Autoloader or dotNet.

No worries; this was just a quick example. Smiley Happy

 

  • Download the attached file (above).
  • If you're using Windows 7, you'll probably need to right click the downloaded file, choose properties, and then hit the unblock button, followed by ok. If not using Windows 7 (i.e., XP, etc.), disregard.
  • Change .ZIP.TXT to just .ZIP file extension.
  • Unzip

 

If you're using 2012 or newer:

 

  • Simply move the resultant ..\BlackBox Layout List Selected.bundle\ folder to %AppData%\Autodesk\ApplicationPlugins\ folder, and start AutoCAD. That's it (hooray Autoloader!). Lemon squeezy.

 

if you're using 2011 or 2010:

 

  • Copy the ..\BlackBox Layout List Selected.bundle\Contents\Windows\2010\bbox_LayoutListSelected18.dll file to any location on your local disk where you have write permission (or to a similar network folder if Acad.Exe.Config has LoadFromRemoteSources XmlAttribute enabled?), and then from within your session of AutoCAD use the NETLOAD Command to load.
  • If you like this, and want it to be loaded for you at startup, let me know, and we can either add to your Acad.lsp (if you have write permission?), or set you up a registry loader which will do the same.

 

Now, if you're using 2009 or older, let me know... I'll have to see if this API feature (the TabSelected Property) was exposed to .NET 3.0 Framework, etc. and attempt to provide you an additional asembly, etc.

 

It sounds like a lot if you're not already familiar, but this is really quite simple once you've done it... Hope this makes (more?) sense now.

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 6 of 12
BlackBox_
in reply to: JoistDetailer


@JoistDetailer wrote:
That looks like it will work. I appreciate your response and effort!

Did you ever get a chance to test this?



"How we think determines what we do, and what we do determines what we get."

Message 7 of 12

No, I didn't.....I just found out that you had replied....I'll try it out in the next few weeks.  thanks!

Message 8 of 12
bhull1985
in reply to: JoistDetailer

"I'll try it out in the next few weeks"

 

 

Lol

@ BB

Sorry buddy, I can test it for you if you're needing to see if it works

 

😄

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 9 of 12
JoistDetailer
in reply to: bhull1985

It will probably be sooner than that, but I'm jammed with "production" work that I need to do first.  I'm kind of a "part time" programmer.  I make tools to help myself (and others, once it's debugged) when time permits.

 

thanks!!

Message 10 of 12
BlackBox_
in reply to: JoistDetailer


@JoistDetailer wrote:

It will probably be sooner than that, but I'm jammed with "production" work that I need to do first.  I'm kind of a "part time" programmer.  I make tools to help myself (and others, once it's debugged) when time permits.

 

thanks!!


No worries; I'm a production guy too.

 

It works fine here (as I tried to demonstrate above), but just wanted to follow up and see if it does what you're after. No rush.

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 11 of 12
robert06
in reply to: BlackBox_

Hi, this looks great, but i could not make the function work in acad 2016 in Win 8.1.

 

I copied the bundle folder "BlackBox Layout List Selected.bundle" to both:

c:\Program Files\Autodesk\ApplicationPlugins\

c:\Program Files (x86)\Autodesk\ApplicationPlugins\

 

Is the content from ApplicationPlugins folders loaded automatically upon Autocad startup in 2016?

 

 

Message 12 of 12
JoistDetailer
in reply to: BlackBox_

I finally got around to checking this out and I can't get it to work.

 

I put the file into the Application Add-ins folder and started AutoCad 2014, but when I enter the command name, it says that the command name is unknown.

 

 

AutoCad 2014 and Windows 7 Professional.

 

Thanks!!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost