Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Obtaining Anno Scale of a saved view

  1. #1
    Member
    Join Date
    2004-11
    Posts
    21
    Login to Give a bone
    0

    Default Obtaining Anno Scale of a saved view

    Hello All,
    I need a little help. I am working on a routine and it would be really helpful if I could programatically obtain the annotation scale within a saved view. I am able to grab the view object, but was surprised that I was not able to discern the annotation scale associated with the view once I analyzed the object data.

    any ideas?
    thanks in advance for any help offered.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    Quote Originally Posted by newfoundfreedom View Post
    HI am able to grab the view object, but was surprised that I was not able to discern the annotation scale associated with the view once I analyzed the object data.
    Do you mean a ViewPort Entity (that resides within PaperSpace), or a View Object (as in an Item of the Views Collection of the ActiveDocument Object)?
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Member
    Join Date
    2004-11
    Posts
    21
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    Quote Originally Posted by RenderMan View Post
    Do you mean a ViewPort Entity (that resides within PaperSpace), or a View Object (as in an Item of the Views Collection of the ActiveDocument Object)?
    Hey RenderMan - the later. I've created a series of modelspace views (View Objects not Viewports) that I need to be able to analyze and pull the Annotation Scale that they were saved with. If you go to the View Dialogue Box and click the view in Model Space you can see the Annotation View that was saved with that view - but it is greyed out. Obviously that information is saved within the View definition - I just cant seem to get to it.

  4. #4
    Member
    Join Date
    2004-11
    Posts
    21
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    To further clarify - I'm not attempting to alter the Annotation Scale saved as part of the View Object Definition. Just need to pull the information to drive a different portion of my routine.

    Thanks

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    Back when 2009 was new, I recall having an issue where there’s a one-way relationship with a named View, where the Annotation scale was saved to the View. When the View was restored, the Drawing Scale (Land Desktop) was made to be the same as the Annotation Scale, yet when manually setting the Drawing Scale, the Annotation was not changed… The source of much frustration for me.

    In any event, given that a quick vlax-Dump-Object of a View Object doesn’t reveal the associated Annotation scale, perhaps digging through the View table record (DXF) will shed more light on what you’re after…? Not everything is exposed to Visual LISP unfortunately.

    Worst case, you hop into Visual Studio, and code yourself a .NET LispFunction Method that will allow LISP to do this for you.

    Good luck!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    Member
    Join Date
    2004-11
    Posts
    21
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    haha - oh is "hopping" into Visual Studio and coding some .NET that easy for you? Unfortunately my skill set has not quite reached such epic proportions.

    Actually, I began with the DXF records which lead me to try grabbing it through the Object Model. It would appear that what you are saying is that I am out-o-luck.

    Thanks RenderMan

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    Quote Originally Posted by newfoundfreedom View Post
    haha - oh is "hopping" into Visual Studio and coding some .NET that easy for you? Unfortunately my skill set has not quite reached such epic proportions.
    Well, an expert at coding .NET I am not, I am able to do some things quite easily:

    GetOwner

    LispKeys


    Quote Originally Posted by newfoundfreedom View Post
    Actually, I began with the DXF records which lead me to try grabbing it through the Object Model. It would appear that what you are saying is that I am out-o-luck.

    Thanks RenderMan
    You're welcome; I'm always happy to not help!

    ... I'll see if I can't dig something up.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    I'm adding this little ditty to my code library for sure....


    vla-Get-ViewAnnoScale

    Returns the annotation scale of a named view

    Code:
    (vla-Get-ViewAnnoScale ViewName)
    ViewName
    A string.

    Return values
    The annotation scale as string, if the ViewName exists within the ViewTable Collection, Nil if the supplied ViewName does not exist.

    Examples

    Code:
    Command: (if (vla-Get-ViewAnnoScale "foo") t nil)
    nil
    
    Command: v
    -VIEW Enter an option [?/Delete/Orthographic/Restore/Save/sEttings/Window]: s
    Enter view name to save: foo
    
    UCSVIEW = 1  UCS will be saved with view
    Command: (if (vla-Get-ViewAnnoScale "foo") t nil)
    T
    
    Command: (vla-Get-ViewAnnoScale "foo")
    "1\" = 50'"


    Attached to this post is a .NET Assembly, compiled to .NET 3.5 and will work for AutoCAD versions 2010 and newer. Be sure to unblock the attached .ZIP file before decompressing, then Simply NETLOAD the assembly into your session of AutoCAD.

    If, like me, you'd prefer to compile the .NET assembly yourself, here's the source code for your use:

    Code:
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.DatabaseServices
    Imports Autodesk.AutoCAD.EditorInput
    Imports Autodesk.AutoCAD.Runtime
    
    Imports System
    
    ' This line is not mandatory, but improves loading performance
    <Assembly: CommandClass(GetType(RenderMan.vlaGetViewAnnoScale))> 
    
    Namespace RenderMan
    
        Public Class vlaGetViewAnnoScale
            '
            ' Initialization message:
            '
            Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
            Public Sub Initialize() Implements _
                IExtensionApplication.Initialize
                Dim ed As Editor = _
                    Application.DocumentManager.MdiActiveDocument.Editor
                ed.WriteMessage(vbLf & "vla-Get-ViewAnnoScale utility loaded. " & vbLf & _
                                "... Another creative innovation by RenderMan, 2012 " & vbLf)
            End Sub
            Public Sub Terminate() Implements _
                IExtensionApplication.Terminate
                Console.WriteLine("Cleaning up... ")
            End Sub
    
            Private Shared ed As Editor = _
                Application.DocumentManager.MdiActiveDocument.Editor
            '
            ' Syntax: (vla-Get-ViewAnnoScale ViewName)
            '
            <LispFunction("vla-Get-ViewAnnoScale")> _
            Public Function vlaGetViewAnnoScale(ByVal args As ResultBuffer)
    
                Try
                    If args = Nothing Then
                        'Throw New ArgumentNullException( _
                        '    "; error: too few arguments")
                        ed.WriteMessage(vbLf & _
                                        "; error: too few arguments " _
                                        & vbLf)
                        Return Nothing
                    End If
    
                    Dim myArgs As Array = args.AsArray()
    
                    If myArgs.Length > 1 Then
                        'Throw New ArgumentException( _
                        '    "; error: too many arguments")
                        ed.WriteMessage(vbLf & _
                                        "; error: too many arguments " _
                                        & vbLf)
                        Return Nothing
                    End If
    
                    Dim acDoc As Document = _
                        Application.DocumentManager.MdiActiveDocument
                    Dim acDb As Database = acDoc.Database
    
                    If myArgs(0).TypeCode <> LispDataType.Text Then
                        ed.WriteMessage(vbLf & _
                                        "; error: bad argument type: stringp " _
                                        & vbLf)
                        Return Nothing
                    End If
    
                    Dim viewName As String = _
                        CType(myArgs.GetValue(0), TypedValue).Value
    
                    Using acTrans As Transaction = _
                        acDb.TransactionManager.StartTransaction()
                        Dim acViewTbl As ViewTable = _
                            acTrans.GetObject(acDb.ViewTableId, _
                                              OpenMode.ForRead)
    
                        If acViewTbl.Has(viewName) = True Then
                            acViewTbl.UpgradeOpen()
                            Dim acViewRec As ViewTableRecord = _
                                acTrans.GetObject(acViewTbl(viewName), OpenMode.ForRead)
                            Dim annoScale As AnnotationScale = acViewRec.AnnotationScale
                            Return annoScale.Name
                        Else
                            Return Nothing
                        End If
    
                        acTrans.Commit()
    
                    End Using
    
                Catch ex As System.Exception
                    ed.WriteMessage(ex.Message)
                    Return Nothing
                End Try
    
            End Function
    
        End Class
    
    End Namespace
    Cheers!
    Attached Files Attached Files
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  9. #9
    Member
    Join Date
    2004-11
    Posts
    21
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    Are you kidding me? Wow RenderMan! Apparently, "hopping into .NET" and whipping out some code really IS that easy for you.
    I can't wait to try this out within my routine. I'll let you know how things work out.

    I dont even really know where to start, I am so blown away that you took on this little project for me.
    Thank man.
    Your not just RenderMan - you are THE Man.

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Obtaining Anno Scale of a saved view

    That is kind of you to say; I'm happy to help.
    Last edited by RenderMan; 2012-04-27 at 02:40 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. 2012: Multiple Anno-Scale Hatches
    By randyspear in forum AutoCAD General
    Replies: 3
    Last Post: 2011-11-09, 06:47 PM
  2. VP scale - Anno scale
    By Bryan Thatcher in forum AutoCAD General
    Replies: 11
    Last Post: 2009-09-10, 03:44 AM
  3. Transfer saved VIEW
    By OCD in forum ACA General
    Replies: 2
    Last Post: 2007-11-01, 12:42 AM
  4. 3d view saved orientation
    By JohnCAVogt in forum Revit Architecture - General
    Replies: 3
    Last Post: 2007-08-11, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •