Results 1 to 4 of 4

Thread: Error in a sample code ?

  1. #1
    100 Club
    Join Date
    2008-04
    Location
    St-Ferdinand, Québec
    Posts
    141
    Login to Give a bone
    0

    Question Error in a sample code ?

    Hi Guys !

    Im realy new to Autocad .NET

    Im using MVS2010 Express and Autocad Architecture 2011

    Im trying a sample in autocad help and I dont know why there are errors ?

    The attached printscreens shows the error in the code below...
    Code:
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.Runtime
    Imports Autodesk.AutoCAD.Interop
    
    Public Class Class3
        <CommandMethod("PrefsSetCursor")> Public Sub PrefsSetCursor()
    
            '' This example sets the crosshairs of the AutoCAD drawing cursor
            '' to full screen.
    
            '' Access the Preferences object
            Dim acPrefComObj As AcadPreferences = Application.Preferences
    
            '' Use the CursorSize property to set the size of the crosshairs
            acPrefComObj.Display.CursorSize = 100
    
        End Sub
    End Class
    Thanks in advance !
    Attached Images Attached Images

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

    Default Re: Error in a sample code ?

    Try this instead (changes in red):

    Code:
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.Runtime
    Imports Autodesk.AutoCAD.Runtime.Interop
    
    Public Class Class3
        <CommandMethod("PrefsSetCursor")> _
        Public Sub PrefsSetCursor()
            Dim acPrefComObj As Object = Application.Preferences
            acPrefComObj.Display.CursorSize = 100
        End Sub
    End Class
    Tested successfully using Civil 3D 2011.

    Also, when you have an error like that, if you hover the red underscore, you'll be presented a drop down button which usually offers some options to correct the error detected.
    "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
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,733
    Login to Give a bone
    0

    Default Re: Error in a sample code ?

    Given the simplicity of the task being performed, this can be written a bit more succinctly:

    Code:
    Imports Autodesk.AutoCAD.Runtime
    
    Public Class Class3
        <CommandMethod("PrefsSetCursor2")> _
        Public Sub PrefsSetCursor2()
            Autodesk.AutoCAD.ApplicationServices. _
                Application.Preferences.Display.CursorSize = 100
        End Sub
    End Class
    "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

  4. #4
    100 Club
    Join Date
    2008-04
    Location
    St-Ferdinand, Québec
    Posts
    141
    Login to Give a bone
    0

    Default Re: Error in a sample code ?

    Quote Originally Posted by RenderMan View Post
    Also, when you have an error like that, if you hover the red underscore, you'll be presented a drop down button which usually offers some options to correct the error detected.
    Good, thanks !

Similar Threads

  1. .Net TRANSMITTALLib Sample Code
    By bernie.snodgrass892799 in forum Dot Net API
    Replies: 6
    Last Post: 2014-01-06, 03:10 PM
  2. Sample code Error
    By r.vetrano in forum Revit - API
    Replies: 2
    Last Post: 2007-07-09, 11:42 AM
  3. Replies: 0
    Last Post: 2006-04-10, 05:38 PM
  4. Replies: 13
    Last Post: 2004-07-29, 11:38 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
  •