Results 1 to 4 of 4

Thread: Working through CP15-1, help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member buddy.brooks's Avatar
    Join Date
    2006-03
    Location
    Lynchburg Virginia
    Posts
    38
    Login to Give a bone
    0

    Red face Working through CP15-1, help

    Help,

    I am trying to work through the CP15-1 tutorial to get a handle on managing sheet sets using VBA. I am using Autocad 2006. I have copied the code for Adding Content to the Sheet Set File. I have tried to write a little sub procedure to launch the code from the click event of a button but I cannot seem to get the call statement right. I keep getting compile errors "missing list seperator or )" I even followed the little box that pops up to show you the syntax, I'm lost here. Here is the code I am trying to use:

    Code:
      
    Sub CreateSubset_Click()
         CreateSubset(oSheetdb1 As AcSmDatabase, strName1 As String, strDesc1 As String,  [strNewSheetLocation1 As String= ""], [strNewSheetDWTLocation1 As String = ""], [strNewSheetDWTLayout1 As String = ""], [bPromptForDWT1 As Boolean = False]) As AcSmSubset
         
    End Sub
    
    
    Private Function CreateSubset(oSheetDb As AcSmDatabase, _
    strName As String, _
    strDesc As String, _
    Optional strNewSheetLocation As String = "", _
    Optional strNewSheetDWTLocation As String = "", _
    Optional strNewSheetDWTLayout As String = "", _
    Optional bPromptForDWT As Boolean = False) As AcSmSubset
    
    '' Create a Subset with the provided name and description
    Set CreateSubset = oSheetDb.GetSheetSet().CreateSubset(strName, strDesc)
    
    '' Get the Folder the Sheet Set is Stored in
    Dim strSheetSetFldr As String
    strSheetSetFldr = Mid(oSheetDb.GetFileName, 1, InStrRev(oSheetDb.GetFileName, "\"))
    
    '' Create a reference to a File Reference object
    Dim oFileRef As IAcSmFileReference
    Set oFileRef = CreateSubset.GetNewSheetLocation
    
    '' Check to see if a path was provided, if not default to the Sheet Set location
    If strNewSheetLocation <> "" Then
          oFileRef.SetFileName strNewSheetLocation
    Else
         oFileRef.SetFileName strSheetSetFldr
    End If
    
    '' Set the new sheet location for the Subset
          CreateSubset.SetNewSheetLocation oFileRef
    '
    ' Create a reference to a Layout Reference object
          Dim oLayoutRef As AcSmAcDbLayoutReference
          Set oLayoutRef = CreateSubset.GetDefDwtLayout
    
    '' Check to see that a default DWT Location was passed in
          If strNewSheetDWTLocation <> "" Then
    
    '' Set the location of the template in the Layout Reference object
          oLayoutRef.SetFileName strNewSheetDWTLocation
    
    '' Set the Layout name for the Layout Reference object
          oLayoutRef.SetName strNewSheetDWTLayout
    
    '' Set the Layout Reference to the Subset
          CreateSubset.SetDefDwtLayout oLayoutRef
          End If
    
    '' Set the Prompt for Template option of the Subset when a new Sheet is created
          CreateSubset.SetPromptForDwt bPromptForDWT
          End Function
    Can someone point me in the right direction? I cannot procede until I can get past this point.


    Bud

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,526
    Login to Give a bone
    0

    Default Re: Working through CP15-1, help

    Code:
      
    Sub CreateSubset_Click()
         CreateSubset(oSheetdb1 As AcSmDatabase, strName1 As String, strDesc1 As String,  [strNewSheetLocation1 As String= ""], [strNewSheetDWTLocation1 As String = ""], [strNewSheetDWTLayout1 As String = ""], [bPromptForDWT1 As Boolean = False]) As AcSmSubset
    When you call a sub/function, you aren't defining variables, just supplying values for them. Therefore, don't use "As type" or brackets for optional parameters. The objects you are passing to the arguments have to be global or have scope within the onclick method.
    C:> ED WORKING....


    LinkedIn

  3. #3
    Member buddy.brooks's Avatar
    Join Date
    2006-03
    Location
    Lynchburg Virginia
    Posts
    38
    Login to Give a bone
    0

    Default Re: Working through CP15-1, help

    Ed,
    That's what I thought I set it up that way to begin with but after reading the help file notes on functions I thought that I would need the parentheses, brackets and types. the text that hovers over the line as I entered the data showed all of that.

    I changed the code to the following, now I am getting an error on the first line of the function that says: "Member exists in an object module from which this object module derives" I have checked everywhere and I cannot find where else any of this line is used.

    Code:
    Sub CreateSubset_Click()
         Dim oSheetDb2 As AcSmDatabase, _
         strName2 As String, _
         strDesc2 As String, _
         strNewSheetLocation2 As String, _
         strNewSheetDWTLocation2 As String, _
         strNewSheetDWTLayout2 As String, _
         bPromptForDWT2 As Boolean
         Dim strCurrentDwgName2 As String
         Dim strShSetFileName2 As String
         
         CreateSubset oSheetDb2, strName2, strDesc2, strNewSheetLocation2, strNewSheetDWTLocation2, strNewSheetDWTLayout2, bPromptForDWT2
         
         
    End Sub
    
    Private Function CreateSubset(oSheetDb As AcSmDatabase, _
    strName As String, _
    strDesc As String, _
    Optional strNewSheetLocation As String = "", _
    Optional strNewSheetDWTLocation As String = "", _
    Optional strNewSheetDWTLayout As String = "", _
    Optional bPromptForDWT As Boolean = False) As AcSmSubset
    '' Create a Subset with the provided name and description
    Set CreateSubset = oSheetDb.GetSheetSet().CreateSubset(strName, strDesc)
    '' Get the Folder the Sheet Set is Stored in
    Dim strSheetSetFldr As String
    strSheetSetFldr = Mid(oSheetDb.GetFileName, 1, InStrRev(oSheetDb.GetFileName, "\"))
    '' Create a reference to a File Reference object
    Dim oFileRef As IAcSmFileReference
    Set oFileRef = CreateSubset.GetNewSheetLocation
    '' Check to see if a path was provided, if not default to the Sheet Set location
    If strNewSheetLocation <> "" Then
    oFileRef.SetFileName strNewSheetLocation
    Else
    oFileRef.SetFileName strSheetSetFldr
    End If
    '' Set the new sheet location for the Subset
    CreateSubset.SetNewSheetLocation oFileRef
    '' Create a reference to a Layout Reference object
    Dim oLayoutRef As AcSmAcDbLayoutReference
    Set oLayoutRef = CreateSubset.GetDefDwtLayout
    '' Check to see that a default DWT Location was passed in
    If strNewSheetDWTLocation <> "" Then
    '' Set the location of the template in the Layout Reference object
    oLayoutRef.SetFileName strNewSheetDWTLocation
    '' Set the Layout name for the Layout Reference object
    oLayoutRef.SetName strNewSheetDWTLayout
    '' Set the Layout Reference to the Subset
    CreateSubset.SetDefDwtLayout oLayoutRef
    End If
    '' Set the Prompt for Template option of the Subset when a new Sheet is created
    CreateSubset.SetPromptForDwt bPromptForDWT
    End Function
    Attached Images Attached Images

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,526
    Login to Give a bone
    0

    Default Re: Working through CP15-1, help

    Quote Originally Posted by buddy.brooks View Post
    the text that hovers over the line as I entered the data showed all of that.
    The signature of the sub you are calling is displayed so that you will know how many arguments are required and what data type they are. If an argument calls for a string type, enter a string in double quotes, enter the name of a variable containing a string, or a function that returns a string.

    I changed the code to the following, now I am getting an error on the first line of the function that says: "Member exists in an object module from which this object module derives" I have checked everywhere and I cannot find where else any of this line is used.
    There are 7 variables defined in the signature, have you searched for all 7?
    C:> ED WORKING....


    LinkedIn

Similar Threads

  1. CP15-4L: LISP for CAD Managers
    By Autodesk University in forum Customization and Programming
    Replies: 0
    Last Post: 2013-04-17, 04:18 AM
  2. CP15-2: .NET Command School
    By Autodesk University in forum Customization and Programming
    Replies: 0
    Last Post: 2013-04-17, 04:17 AM
  3. CP15-1: Taking a Look at the Sheet Set Object.
    By Autodesk University in forum Customization and Programming
    Replies: 0
    Last Post: 2013-04-17, 04:17 AM
  4. Replies: 1
    Last Post: 2012-02-16, 06:57 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
  •