PDA

View Full Version : Multiple Paper Space Layouts, Multiple Views and only One ViewPort in VB.NET



turkish
9th Sep 2010, 05:56 pm
Hello to everybody,

I'm writing my first message as I started developing my first App.

The thing is I have a dwg with the same number of paper space layouts and views, and the same viewport for all the paper space's layouts.

So the problem is: I'm stuck trying to link the viewport of each layout to the correspondig view.

I attach in .txt the code for VB.NET and appreciate if anybody can help me in this very first real project.

Thanks for helping.:)22943

SEANT
10th Sep 2010, 08:39 am
Are you trying to get a Viewport that has a particular view, or set the view of a particular viewport?

In “Sub CloneView()”, what are the settings for the variables in this line:

acViewTblRec.CenterPoint() = New Point2d(posX + dimX / 2, posY + dimY / 2)

turkish
10th Sep 2010, 09:19 am
Hi Seant,

First af all, thanks for your reply.

I'm trying to set the view of a particular viewport, but the thing is in de dwg I only have one viewport (the same viewport for all the paper space's layout).
If I have understood how Autocad's database works this means than each time I select a different paper space layout, the viewport drawed in this layout becomes the active viewport in the database.

So I think that I need to program the next steps:
1) select the right paper space (the new cloned layout)
2) associate the new view created with this paper space (what I suppose sets the view to the viewport).

I can send you the cad file so you can have a look (if have spare time :cry:)

The settings for the variables are geometrical positions, distances, etc., I send the ones I have for my trial:

Dim dimX As Double = 80.586
Dim dimY As Double = 56.232
Dim deltaX As Double = 9.8119
Dim deltaY As Double = 7.803
Dim matX As Integer = 1
Dim matY As Integer = 4
Dim posX As Double = (matX - 1) * (dimX + deltaX)
Dim posY As Double = (1 - matY) * (dimY + deltaY)

Thank you again for your time.

SEANT
10th Sep 2010, 09:36 am
Each Layout has an initial Viewport, even if there are no “Floating Viewports” present. It’s a rather confusing aspect setup by Autodesk. See this current thread at "The Swamp" :

http://www.theswamp.org/index.php?topic=34837.0

I should have some time this weekend so, yes, upload a cad file with all the specific parameters.

turkish
10th Sep 2010, 10:19 am
I'll have a look into "the swamp", cause right now I really feel myself sinking into it.

I've attached a new txt with very basic instructions of the way to use de dll and the base dwg I have to deal with.

I have to generate a whole array of presentations and views but I couldn't get the first milestone as I've told.

Thanks.:)2295822959

SEANT
13th Sep 2010, 10:10 am
I can’t find a straightforward method to assign a “Saved View” to a paperspace viewport. We must be missing something as that really should be possible with the API.

I haven’t invested considerable time in a search but . . . . neither is it readily apparent that a viewport’s view can be modified without first activating the Layout. I’ll look into that further when I get time.

Would activating the layout first be acceptable to the workflow of your routine?

turkish
13th Sep 2010, 10:19 am
Yes, there's no problem to activate the layout first.

I haven't solved it yet, so thank you again for your time.

SEANT
13th Sep 2010, 10:59 am
I'll try to get something ready for upload tomorrow.

SEANT
14th Sep 2010, 09:24 am
See if this works out.

Warning: Limited Testing!


<CommandMethod("AssignView")> _
Public Sub AssignView()
'' Get the current database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
Dim myLayoutDictionary As DBDictionary = acCurDb.LayoutDictionaryId.GetObject(OpenMode.ForR ead)
Dim oid As ObjectId = myLayoutDictionary.Item("E10")
Dim myLayout As Layout = DirectCast(acTrans.GetObject(oid, OpenMode.ForWrite), Layout)
Dim ltman As LayoutManager = LayoutManager.Current
Application.SetSystemVariable("TILEMODE", 0)
acDoc.Editor.SwitchToPaperSpace()
ltman.CurrentLayout = "E10"
Dim oids As ObjectIdCollection = myLayout.GetViewports()
Dim vp As Viewport = DirectCast(acTrans.GetObject(oids(1), OpenMode.ForWrite), Viewport)
Dim vCenter As Point2d = New Point2d(posX + dimX / 2, posY + dimY / 2)
Dim locked As Boolean = vp.Locked
If (locked) Then vp.Locked = False
vp.ViewCenter = vCenter
vp.UpdateDisplay()
vp.Locked = locked
acTrans.Commit()
End Using
End Sub

turkish
14th Sep 2010, 09:46 am
Great, it works perfect.

This is not the method I was trying but it solves my problem.

Thank you very much.

SEANT
14th Sep 2010, 10:24 am
Great, it works perfect.

This is not the method I was trying but it solves my problem.

Thank you very much.

The whole process does need more investigation. When time permits, perhaps. :)