Results 1 to 10 of 10

Thread: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

  1. #1
    Member
    Join Date
    2011-06
    Posts
    28
    Login to Give a bone
    0

    Default Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    Please forgive me, I am very green...

    I am developing application level macros (I guess you know that by now) for RST 2011. Now I want to create and populate some forms.

    Creating the forms, I got it. Populating the forms with data from the model...not a clue.

    I have used drop-downs, but I cannot figure out how to link model data to the form. Can I even do this in an application macro? If not, that's fine, I'll try it in a proper add-in.

    So, the question stands, how do i link model data with the form? I see there is a data source option, where I can browse around and add data, but I still can't get it to populate (I usually receive an error message in German- something about a module...)

    Also, how do I pass the information between forms and other 'pieces' of my add-in. I've seen this done with a class which references the document, but beyond that I haven't a clue how to do this...

    Does any of this text make sense?
    Any help is greatly appreciated.
    Matt

  2. #2
    I could stop if I wanted to
    Join Date
    2004-06
    Location
    Port Moody, BC
    Posts
    349
    Login to Give a bone
    0

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    I am by no means an expert, however here is what I would do as a fellow greeny!

    I will use a combo box as an example and populate with WallType Names:

    Define the form with a combo box, name the combo box cboDrew (or whatever)

    Get the list of Wall Types from the document

    For each walltype, put its name into the combo box

    show the form.

    I use vb, so here is a sort of example:

    Dim myfrm As New Form1
    Dim collector As New Autodesk.Revit.DB.FilteredElementCollector(doc)
    Dim collection As ICollection(Of Autodesk.Revit.DB.Element) = collector.OfClass(GetType(Autodesk.Revit.DB.WallType)).ToElements()
    For Each Walltype As WallType In collection
    myfrm.cboDrew.Items.Add(Walltype.Name.ToString)
    Next
    myfrm.ShowDialog()

    Am I in the correct ball park for what you were looking for?

  3. #3
    Member
    Join Date
    2011-06
    Posts
    28
    Login to Give a bone
    0

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    I will try it on the way home tonight...thanks for the reply.
    I'll let you know how it turns-out.

    Matt

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

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    That's the usual method for populating a control. As to the DataSource property, that takes a DataSet as an argument. This sets up automatic data binding for the form. Controls can then access tables, etc from the dataset. This is intended for an SQL table or database.
    C:> ED WORKING....


    LinkedIn

  5. #5
    Member
    Join Date
    2011-06
    Posts
    28
    Login to Give a bone
    0

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    I have not tried this yet (no time) but I'm starting to look a little more into forms. I've used the form-designer from VSTA in the past, but that was months ago, and I never go anything actually running.

    What is still unclear to me:
    I want to take information from the form, and bring it back into my application macros. The form is an object within the project, but I am running all of my code from the ThisApplication.vb (object / module?)
    How do I get the information from the form, into ThisApplication.vb?
    I've tried Call and CallbyName, but that doesn't seem to work.

    Can anyone explain how this works?

    Thanks.
    Matt

  6. #6
    Member
    Join Date
    2011-06
    Posts
    28
    Login to Give a bone
    0

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    It looks like you are in the right ballpark...but I cannot access the ICollection object. Where does it come from?

  7. #7
    Member
    Join Date
    2011-06
    Posts
    28
    Login to Give a bone
    0

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    Decided to check back on this topic. ICollection - in which namespace can I find this object?!?

  8. #8
    Member
    Join Date
    2011-06
    Posts
    28
    Login to Give a bone
    0

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    Bump.

    Does anyone know where I can find the ICollection object (as mentioned by drewj)?

    Thanks,
    Matt

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

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    His code is using Generics to cast a bunch of Element objects into a collection. If you are trying to find objects in the framework, use Object Browser. Search for iCollection and find out what class it belongs to (Hint: System.Collections), then add a reference to the class and an Imports statement to the declarations section of your code.
    C:> ED WORKING....


    LinkedIn

  10. #10
    Active Member
    Join Date
    2011-01
    Posts
    87
    Login to Give a bone
    0

    Default Re: Populating Forms (Combo Boxes, Check Boxesk) Passing Arguments between forms

    I think the easiest method is to write a temporary tab or comma delimited file then delete it when you're done. This is how I overcame a large dataset from 11 parameters from an unlimited elements selection set. It worked very well and I could sort it within the file so when I loaded the form, it was sorted.

Similar Threads

  1. Using Windows Forms vb
    By drewj in forum Revit - API
    Replies: 1
    Last Post: 2012-07-19, 08:43 PM
  2. Some Void Forms...
    By brent.130528 in forum Revit Architecture - General
    Replies: 1
    Last Post: 2010-01-27, 12:15 AM
  3. Populating combo box created on the fly
    By gdaniels in forum VBA/COM Interop
    Replies: 3
    Last Post: 2008-04-26, 04:42 PM
  4. The Different Forms of 3d
    By mlawler in forum DV - The 3rd Dimension
    Replies: 3
    Last Post: 2005-12-12, 09:22 AM
  5. Passing selection sets as arguments
    By mcoonrod in forum AutoLISP
    Replies: 4
    Last Post: 2005-10-21, 05:51 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
  •