Jump to content

Recommended Posts

Posted

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.:)CODES.txt

Posted

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)

Posted

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.

Posted

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.

Posted

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.:)Drawing1.dwg

CODES_COMPLETE.txt

Posted

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?

Posted

Yes, there's no problem to activate the layout first.

 

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

Posted

I'll try to get something ready for upload tomorrow.

Posted

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.ForRead)
           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

Posted

Great, it works perfect.

 

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

 

Thank you very much.

Posted
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. :)

  • 10 years later...
Posted (edited)

@SEANThow to apply this part:

 

Dim oid As ObjectId = myLayoutDictionary.Item("E10")

 

to C# withhout loop because i has test myLayoutDictionary. Item("E10") in c# no method for item

Edited by CADTutor
Added code to code block

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...