Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Vario

Pages: [1]
1
Layouts and printing / Move Layout to other position
« on: February 07, 2012, 02:23:49 PM »
Hi!
according to another problem i tried a workaround, but now im stuck...

how can i move a layout to another tabposition?
if a change the Property Tabindex, there is no effect.
even the property TabSelected = true has no effect selecting the Layout. The only way where it is possible is using the layoutmanager.
but for the other property tabindex i cannot find a function or property which works...

anybody know?

2
Layouts and printing / Re: Export each Layout and Modelspace to new Drawing
« on: February 06, 2012, 07:56:38 AM »
hi!
thank you for your reply and ideas, maybe i have to say a little bit more.
i want to include the functionality into a summary of different conversions. so i dont know it its possible to open drawings during an other active command.
my first idea was to iterrate through the layouts delete each except de modelspace and one layout and then saveas. but this is not possible, because the transaction is still opened and then i cannot save the database.
 
here is my last try, but it works not properly enough. the layouts are exported thats fine, but if i open the drawings i have errors in it and i need a recover.
this errors are in each drawing except the one with the first layout from the original.
so the first layouts is exported correctly, the drawing has no errors and works fine, but the rest needs a recover...

the next questions is, if it is good to use the Wblock Function to get a temporary Database. i'll loose the template settings from the original or?
maybe anybody has another good idea.

[UPDATE] i got it that the files are opened correctly without errors, but i still have 2 layouts in each new drawing. the one which should be there and a new layout named Layout1 with the content of the original layout with tabindex 1. i deleted it in the code, but it remains in the drawing ???
should i set the taborder property of the layout which should remain in the drawing to 1?

Code: [Select]
public void ExportLayouts(Document acDwg)
      DocumentLock acDocLock = null;
            int i = 0;
            Database acDB = null;
            Transaction acTrans = null;
            BlockTable acBT = null;
            BlockTableRecord acBTR = null;
            SymbolTableEnumerator acBTRE = null;
            Layout acLayout = null;
            Layout acLayoutToExport = null;
            List<String> liExportedLayouts = new List<string>();
            FileInfo fiDrawing = new FileInfo(mydwg.Name);
            try
            {
                //acDwg = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
               
                acDocLock = acDwg.LockDocument();
                acDB = HostApplicationServices.WorkingDatabase;

                acBT = (BlockTable)(acDB.BlockTableId.GetObject(OpenMode.ForWrite));
                acBTRE = acBT.GetEnumerator();

                while (acBTRE.MoveNext())
                {
                    if (acBTRE.Current.IsErased == false)
                    {
                        acBTR = (BlockTableRecord)(acBTRE.Current.GetObject(OpenMode.ForWrite));
                        if (acBTR.IsLayout)
                        {
                            acLayout = (Layout)(acBTR.LayoutId.GetObject(OpenMode.ForWrite));
                            if (acLayout.ModelType == false)
                            {
                                i += 1;
                            }
                        }
                    }
                }
                LayoutManager.Current.CurrentLayout = "Model";

                for (int j = 1; j <= i; j++)
                {
                    Database acTmpDatabase = new Database(true, false);
                    acLayoutToExport = null;

                    acTmpDatabase = acDB.Wblock();
                    acTrans = acTmpDatabase.TransactionManager.StartTransaction();

                    using (acTrans)
                    {
                        acBT = (BlockTable)(acTrans.GetObject(acTmpDatabase.BlockTableId, OpenMode.ForRead));
                        acBTRE = acBT.GetEnumerator();

                        while (acBTRE.MoveNext())
                        {
                            if (acBTRE.Current.IsErased == false)
                            {
                                acBTR = (BlockTableRecord)(acTrans.GetObject(acBTRE.Current, OpenMode.ForRead));
                                if (acBTR.IsLayout)
                                {
                                    acLayout = (Layout)(acTrans.GetObject(acBTR.LayoutId, OpenMode.ForWrite));
                                    if (acLayout.ModelType == false)
                                    {
                                        if (acLayoutToExport == null)
                                        {
                                            if (liExportedLayouts.Contains(acLayout.LayoutName) == false)
                                            {
                                                acLayoutToExport = acLayout;
                                                liExportedLayouts.Add(acLayout.LayoutName);
                                                acLayout.DowngradeOpen();
                                                continue;
                                            }
                                            else
                                                acLayout.Erase();
                                        }
                                        else
                                            acLayout.Erase();
                                    }
                                }
                            }
                        }
                        acTrans.Commit();
                    }
                    acTmpDatabase.CloseInput(true);

                    if (acLayoutToExport != null)
                    {
                        if (File.Exists(fiDrawing.Directory.FullName + "\\" + acLayoutToExport.LayoutName + fiDrawing.Extension) == false)
                            acTmpDatabase.SaveAs(fiDrawing.Directory.FullName + "\\" + acLayoutToExport.LayoutName + fiDrawing.Extension, DwgVersion.AC1024);
                        else
                            acTmpDatabase.SaveAs(fiDrawing.Directory.FullName + "\\" + acLayoutToExport.LayoutName + sTimeStamp + fiDrawing.Extension, DwgVersion.AC1024);
                    }
                    else
                    {
                        acTmpDatabase.SaveAs(fiDrawing.Directory.FullName + "\\" + Path.GetFileNameWithoutExtension(fiDrawing.FullName) + fiDrawing.Extension, DwgVersion.AC1024);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.Stacktrace);
            }
            finally
            {
                if (acDocLock != null)
                {
                    acDocLock.Dispose();
                }
            }
        }
       

3
Layouts and printing / Export each Layout and Modelspace to new Drawing
« on: February 03, 2012, 07:34:24 AM »
Hi!
I wanna do the following things.
Drawing with X Layouts.

Export each Layout to a new Drawing with Modelspace.
How did i try it:
Iterrate all Layouts in a loop.
Delete all except Modelspace and one Layout. Remember the Layout and save the current database to a new File.
so now repeat this process for the rest of the Layouts.

the layouts are exported, but if i open a drawing, i have to recover it except the drawing with the layout which was on the first position of the original drawing.
so my question, where is the difference between the drawings?
is there a special property in a layout if its the first in a drawing?


Pages: [1]