Author Topic: acedCreateEnhancedViewportOnDrop(Add a sheet view to current sheet of SheetSet)  (Read 3390 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6150
In case anyone needs it.
Works okay so far and works like adding through sheetset without the jigging.
acedCreateEnhancedViewportOnDrop
Quote
  • const ACHAR * filename Input fully qualified file name of the DWG file that contains the view; if null, this is assumed to be the current AcDbDatabase 
  • const ACHAR * viewName  Input name of an AcDbViewTableRecord in the drawing referred to by filename 
  • const AcGePoint2d location  Input desired location of the new viewport in paperspace coordinates of the current layout 
  • double scale Input scale of the model space within the viewport to the paperspace the viewport is being created in; this effectively dictates the size of the viewport 
  • AcDbObjectId labelBlockId  Input object ID of the label block definition to be displayed below the viewport 
  • AcDbObjectId& sheetViewId  Output the ID of an AcDbViewTableRecord for a paperspace view showing the viewport, the label block, and a small padding area around the border on success, or AcDbObjectId::kNull otherwise 
  • AcDbObjectId& viewportId  Output set to the ID of the AcDbViewport created by this method on success, or AcDbObjectId::kNull otherwise 

This function creates an AcDbViewport in the current layout of the current drawing database. It takes the referred to file, XREFs it in, creates a viewport at the specified location at a size determined from the view's model size combined with the scale factor, and sets the viewing parameters of the viewport to those of the view, including the views layer state. This method provides no user interaction.

The insertion point of the block definition should be appropriate for the labelBlockId block to be inserted in the layout at the lower-left corner of the viewport.

Returns eOk on success.



Only tested very little but if the current layout is part of a sheet set it will add it the view to the sheet set.

This is for 2015 64 bit

Code - C#: [Select]
  1.         [CommandMethod("DropTest")]
  2.         public void DropTest()
  3.         {
  4.             ObjectId viewId;
  5.             ObjectId vportId;
  6.             acedCreateEnhancedViewportOnDrop(@"J:\Current Jobs\Jobs-14\1407 - Jackson Co K-8\Drawings\_Source Files\e_overall-PWR.dwg", "C1", Point2d.Origin, 1.0 / 96, ObjectId.Null, out viewId, out vportId);
  7.         }
  8.        
  9.         [DllImport("accore.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl,
  10.             EntryPoint ="?acedCreateEnhancedViewportOnDrop@@YA?AW4ErrorStatus@Acad@@PEB_W0VAcGePoint2d@@NVAcDbObjectId@@AEAV4@3@Z")]
  11.         private static extern int acedCreateEnhancedViewportOnDrop(string fileName, string viewName, Point2d position,
  12.             double scale, ObjectId labelBlock, out ObjectId viewId, out ObjectId vportId);
  13.  
  14.  

pBe

  • Bull Frog
  • Posts: 402
Hi Jeff, I'm aware that this is an old topic but this is a great idea, adding a new sheet view set on a sheet set manually takes a lot of time per view.

Can you add more information on how to  use the code at post #1

BTW, are you having issues using sheet sets with cloud servers?

Jeff H

  • Needs a day job
  • Posts: 6150
Hi Jeff, I'm aware that this is an old topic but this is a great idea, adding a new sheet view set on a sheet set manually takes a lot of time per view.

Can you add more information on how to  use the code at post #1
The method is not exposed and using pinvoke
https://docs.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke
dumpbin.exe can be used to retrieve the function signatures and  here are some results for different versions of acad dlls http://www.theswamp.org/index.php?topic=41527.msg499429#msg499429

Here is an example of pinvoke using a win32 unmanaged function
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute?view=net-6.0

So once you get that you have the function information and using the DllimportAttribute you can pass in the arguments to the parameters list below that updated for the function in first post to match the dot net types
  • String filename Input fully qualified file name of the DWG file that contains the view; if null, this is assumed to be the current Database
  • String viewName  Input name of an ViewTableRecord in the drawing referred to by filename
  • Point2d position Input desired location of the new viewport in paperspace coordinates of the current layout
  • double scale Input scale of the model space within the viewport to the paperspace the viewport is being created in; this effectively dictates the size of the viewport
  • ObjectId  labelBlock  Input object ID of the label block definition to be displayed below the viewport
  • out ObjectId  viewId  Output the ID of an ViewTableRecord for a paperspace view showing the viewport, the label block, and a small padding area around the border on success, or ObjectId.Null otherwise
  • out ObjectId  vportId  Output set to the ID of the Viewport created by this method on success, or ObjectId.Null otherwise
So looks like you will have to have a view created, and if the view is in the current drawing then would pass in a empty string to first argument filename
If you want to use a label block like you can through sheet sets it looks like you need to make sure the block is defined in the drawing and gets its ObjectID and pass that in. Example below I passed in ObjectID.Null so it ignored it and did not place one

Like when using sheetset manager to place views it creates a layout view and viewport which will update the ObjectID passed in last two arguments with the ObjectIDs of the created view and viewport. If you pass in a ID for a label block to be used looks like it doesn't gives you the ID the block reference for the label block

BTW, are you having issues using sheet sets with cloud servers?
I have not used them on a cloud server but from my understanding 2023 has improvements for that and is currently being updated to fix bugs and add more functionality

pBe

  • Bull Frog
  • Posts: 402
Thank you so much for taking time to explain logic behind it Jeff H.
I'll try to implement this and let you know how it goes

Cheers