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
See this article it may helps
http://adndevblog.typepad.com/autocad/2012/08/create-a-new-sheet-using-com-sheetset-api.html
Thanks for the reply but that article does not address the problem.
James
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.
James
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.
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; }
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
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
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.
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
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.