.NET

Reply
Distinguished Contributor
CADdaddy.com
Posts: 208
Registered: ‎04-10-2005
Message 1 of 9 (401 Views)

finding sheet set properties for current drawing

401 Views, 8 Replies
04-02-2013 04:22 PM

I am writing a program acts on the current drawing by using data in the SSM.  If the current drawing is found to be a member of a sheet set (using sysvar SSFOUND) it cycles through all the sheet in the sheet set looking for a sheet entry that matches.  Sometimes a match is not found because the layout name in the SSM does not match the layout  name in the current tab (sysvar CTAB).  Is there a more directly way...and one that works?  I just need a reliable way to get the AcSmSheet object the correlates to the current drawing.

 

James LeVieux

 

SSM layout problem2.PNG

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 9 (384 Views)

Re: finding sheet set properties for current drawing

04-02-2013 10:12 PM in reply to: CADdaddy.com

See this article it may helps

http://adndevblog.typepad.com/autocad/2012/08/create-a-new-sheet-using-com-sheetset-api.html

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
CADdaddy.com
Posts: 208
Registered: ‎04-10-2005
Message 3 of 9 (367 Views)

Re: finding sheet set properties for current drawing

04-03-2013 08:28 AM in reply to: Hallex

Thanks for the reply but that article does not address the problem.

 

James

Distinguished Contributor
CADdaddy.com
Posts: 208
Registered: ‎04-10-2005
Message 4 of 9 (360 Views)

Re: finding sheet set properties for current drawing

04-03-2013 10:25 AM in reply to: CADdaddy.com

IAcSmSheetSetMgr.GetSheetFromLayout() looks promising.  No documentation naturally.  Can anyone tell me how to aquire this AXDBLib.AcadObject as a layout?  I was able to add the reference to AXDBlib but I just don't know the AutoCAD API well enough to extract the object in question.

 

GetSheetFromLayout.PNG

 

James

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 5 of 9 (352 Views)

Re: finding sheet set properties for current drawing

04-03-2013 06:12 PM in reply to: CADdaddy.com

You get the Layout's managed wrapper object, and pass the value of it's AcadObject property. The Layout object can be obtained from the LayoutId property of a BlockTableRecord.

 

If you're not familiar with any of those managed API objects mentioned above, download the available learning materials from Autodesk's web site.

 

Distinguished Contributor
CADdaddy.com
Posts: 208
Registered: ‎04-10-2005
Message 6 of 9 (336 Views)

Re: finding sheet set properties for current drawing

04-04-2013 09:20 AM in reply to: DiningPhilosopher

Thanks!... that got me on the right track.  This basically works:

 

        public AcSmSheet GetCurrentSheet()
        {

            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            AcSmSheet sheet=new AcSmSheet();
            AXDBLib.AcadObject obj;   //requires AXDBlib reference
            LayoutManager LM = LayoutManager.Current;
            
            using (Transaction acTrans = doc.Database.TransactionManager.StartTransaction())
            {
                try
                {
                    obj = (AXDBLib.AcadObject)LM.GetLayoutId(LM.CurrentLayout).GetObject(OpenMode.ForRead).AcadObject;
                    sheetSetMgr.GetSheetFromLayout(obj, out sheet);
                }
                catch(System.Exception e)
                {
                    MessageBox.Show("There was an error getting the sheet set info for this layout: " + e.Message);
                }
             }
            return sheet;

        }

 

Member
tim.nell
Posts: 3
Registered: ‎08-12-2013
Message 7 of 9 (113 Views)

Re: finding sheet set properties for current drawing

09-16-2014 12:16 AM in reply to: CADdaddy.com

As I have used this and confirm it works but in VB I thouht I give the conversion for those that may like it.

Getting Documentation for Sheet Set is a pain in the neck so stuff like this is a great help

 

Thanks

 

 

 

 

Imports ACSMCOMPONENTS20Lib
'this is for Autocad 2015
'Change to suit Aautocad version

'Converted by Tim Nell Sept 2014
'Tested in Autocad 2015

Public Function GetCurrentSheet() As AcSmSheet

        Dim Thisdoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim Claymgr As LayoutManager = LayoutManager.Current
        Dim CurrSheet As New AcSmSheet
        Dim AXDBlibObj As AXDBLib.AcadObject

        Dim sheetSetManager As IAcSmSheetSetMgr = New AcSmSheetSetMgr

        Using trans As Transaction = Thisdoc.Database.TransactionManager.StartTransaction
            Try
                AXDBlibObj = Claymgr.GetLayoutId(Claymgr.CurrentLayout).GetObject(OpenMode.ForRead).AcadObject
                sheetSetManager.GetSheetFromLayout(AXDBlibObj, CurrSheet)

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try

            Return CurrSheet

        End Using
        



    End Function

 

Active Contributor
jeffrey.ries
Posts: 27
Registered: ‎09-25-2011
Message 8 of 9 (101 Views)

Re: finding sheet set properties for current drawing

09-17-2014 10:38 AM in reply to: tim.nell

I cannot seem to get this to work.  I also previously converted the original code and assumed it converted poorly, but I tried your tested code and it also errors for me as well.

 

It gets to the GetSheetFromLayout line and states that it cannot cast a 'System._ComObject' to a 'AXDBLib.AcadObject'

 

This is such an obscure exercise that I cannot seem to find any others out there attempting it - other than this thread.

 

Any ideas?

 

Thanks,

Jeff

Member
tim.nell
Posts: 3
Registered: ‎08-12-2013
Message 9 of 9 (51 Views)

Re: finding sheet set properties for current drawing

10-12-2014 09:56 PM in reply to: jeffrey.ries

Only having a quick quess as it works at this end.

 

Need to make sure there is a reference into your project to "AcSmComponents20 1.0 Type Library" & also Autocad/ObjectDBX Common 20.0 Type Library"

The version 20.0 refers to Acad 2015 so adjust accordinly.

 

It is a tricky thing to make sure all the cards are aligned otherwise they will fall down.

 

 

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!