.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

finding sheet set properties for current drawing

10 REPLIES 10
Reply
Message 1 of 11
CADdaddy.com
1230 Views, 10 Replies

finding sheet set properties for current drawing

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

10 REPLIES 10
Message 2 of 11
Hallex
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
Message 3 of 11
CADdaddy.com
in reply to: Hallex

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

 

James

Message 4 of 11
CADdaddy.com
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

Message 5 of 11

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.

 

Message 6 of 11

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;

        }

 

Message 7 of 11
tim.nell
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

 

Message 8 of 11
jeffrey.ries
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

Message 9 of 11
tim.nell
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.

 

 

 

 

Message 10 of 11
TimNell
in reply to: tim.nell

Just for for Anyone reading this. I have had trouble with the original code written for 2014 & 2015 working in 2016. This may not work in versions of autocad after 2015. If anyone has success please post it here.

 

Thanks

Message 11 of 11
tim_nellNEM49
in reply to: TimNell

I have tested the Vb version recently and it was working BUT.

Need to make sure you have a current sheetset and sheet open. It has not error checking in it.

Hope it help someone

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost