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

Thread: Change Shared Parameters in linked file Rooms

  1. #1
    I could stop if I wanted to
    Join Date
    2006-09
    Posts
    259
    Login to Give a bone
    0

    Default Change Shared Parameters in linked file Rooms

    Hello,

    Is it possible to change values of some shared parameters (mainly text) of rooms that are part of linked files? I searched here in the forum but couldn't find anything on this subject. can you please point me in the right direction, if this is possible to do?

    Many thanks in anticipation of your help.

    regards

  2. #2
    I could stop if I wanted to Danny Polkinhorn's Avatar
    Join Date
    2003-12
    Location
    San Francisco, CA
    Posts
    448
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    You would need to have the linked document open in order to change any data in it. At this time, it's not possible to open a Revit document with the API, so you would need to open the linked document manually prior to making changes with the API.

    HTH,
    Last edited by Danny Polkinhorn; 2010-05-25 at 10:31 PM.

  3. #3
    I could stop if I wanted to
    Join Date
    2006-09
    Posts
    259
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    Many thanks Danny for your quick response.

    I thought when i have host file open, linked files are open/loaded in the memory in the same revit session. I gather that Autodesk.Revit.Element.Instance class can be used to retrieve elements from linked file but i couldnt find if we can chane elements or parameters or not.

    Let me explain briefly what i want to achieve. We have a big multi storey building project. The building is divided in two revit project files based on zones instead of levels. So a level is split between two files. So in broad terms, file A.rvt has left wing for levels 1 to 4 and file B.rvt has right wing for levels 1 to 4. There are 6 departments in the whole buildings. A deprtment would also be shared between two or more levels, i.e. DEPT A will have some rooms on level 1 and some rooms on level 2. Rooms will have shared parameter called Department-TargetdArea, Area Difference (actual - target department), percentage department area difference, percentage range (0 to 10%, above 10%, 0 to -10%, and below -10%). When we open host file and generate department schedule including two linked files rooms it shows departments areas and target areas but area difference, percentage, and percentagerabge fields are emptyy. So what i want to do is to calculate those fields using actual total department area and target area values. I then use percentagerange p.aramter to gemerate room color scheme so i can visually see area over under analysis.

    Is this possible?

    Thanks in anticipation of your help.

    Cheers

  4. #4
    I could stop if I wanted to Danny Polkinhorn's Avatar
    Join Date
    2003-12
    Location
    San Francisco, CA
    Posts
    448
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    Sorry, I need to correct that earlier statement. You can open additional documents with the API, but any changes you need to make to parameter values must be done with an open document, not through a linked file. Determine what your linked files are, open them, make parameter changes.

    In answer to your question, you have read-only access to the data in a linked file, so yes, you can read the data and do your calculations, but changes to parameters must be done in an open document.

  5. #5
    I could stop if I wanted to
    Join Date
    2006-09
    Posts
    259
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    Thanks very much Danny.

    So i take it that currently it is not possible to achieve what i described above. Right? Because rooms and deparment information is stored in two seperate linked files and we get department total area in host file when we combine two revit files. I guess i can calculate area difference and percentage area difference and percentagerange and store them in the host file but will not be able to push them to linked files. So i cant genrate color scheme for department area over under anallysis. Right?

  6. #6
    100 Club
    Join Date
    2004-02
    Location
    Brookline, MA
    Posts
    186
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    I may be misunderstanding the requirement, but I think you can achieve this...

    As you mentioned, you have to look for the Instance elements, and use that to retrieve the name of the linked model (it is one of the parameters on it).

    Then look through the Application.Documents collection for a matching name which is already in memory. You can then start working on that in-memory document.

    (NOTE: you will need to make sure that you're explicitly handling transactions for the non-current Revit model).

    Good Luck,
    Matt

  7. #7
    I could stop if I wanted to
    Join Date
    2006-09
    Posts
    259
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    Thanks very much Matt. Much appreciated.

    I have been through your AU2009 notes (CP204-3, C# sample) where you have a code snippet to deal with linked files. I also refered to Buildingcoder, Jeremy's CmdLinkedFiles.CS code snnipet to get the list of linked files in active document.

    I implemented both snippets in the Revit SDK Rooms sample to get all departments info from linked files rooms and show them in datagrid view. But when I run the command it shows blank datagrid view. I have commented the part of the sample code that I don't need, for instance list of rooms, tag or non tag etc. I have only kept a datagrid view that is showing department area total.

    Please find attached two zip files. One contains revised Rooms csproject files and the other one contains three (one HOST.rvt and two links DEPT_A.rvt and DEPT_B.rvt) Revit files that I am testing this code on.

    Can you please have a look at the files and suggest solution for this?
    Many thanks in anticipation.

    ** I am using Revit Architecture 2010 X64 with Visual Studio C# 2008 Express.
    Regards
    Attached Files Attached Files
    Last edited by pfaudler; 2010-05-26 at 04:38 PM. Reason: System information added

  8. #8
    I could stop if I wanted to
    Join Date
    2006-09
    Posts
    259
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    I have just tested the code with two message boxes before and after each document transaction, as below. The messageboxes appear three times so the code does iterate through linked files but not retrieving rooms from them.

    Foreach (Documents document in m_revit.Documents)
    {
    messagebox.show("transaction begins");
    document.transactionbegin();

    //Revit SDK Rooms code to extract rooms generate rooms list. Please see attched code zip file above.

    ...
    ...
    ...
    document.transactionend();
    messagebox.show("transaction ends");
    }// foreach ends

    After messageboxes, at the end blank datagrid comeup. So i understand that somehow the code is not getting rooms and hence rooms information from linked files.

    Can someone please help?

    Many thanks in anticipation.

    Regards

  9. #9
    I could stop if I wanted to
    Join Date
    2006-09
    Posts
    259
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    Quote Originally Posted by mmason.65315 View Post
    I may be misunderstanding the requirement, but I think you can achieve this...

    As you mentioned, you have to look for the Instance elements, and use that to retrieve the name of the linked model (it is one of the parameters on it).

    Then look through the Application.Documents collection for a matching name which is already in memory. You can then start working on that in-memory document.

    (NOTE: you will need to make sure that you're explicitly handling transactions for the non-current Revit model).

    Good Luck,
    Matt
    Matt,

    I have managed to develop this code and it more or less works. It works on a single open/active document but when you have two open documents it goes through first document BEGIN and END TRANSACTION and then enters into second document transaction (goes inside document.begintransaction() and throws following error:

    "Object reference not set to an instance of an object."

    Basically I am going through each room object and extracting Department, Department Target Area, Room Area etc.

    Please code snnipet below.

    CODE#
    foreach (Document document in m_revit.Documents)
    {


    document.BeginTransaction();

    ElementIterator elementIterator = document.get_Elements(typeof(Room));
    elementIterator.Reset();

    // try to find all the rooms in the project and add to the list
    while (elementIterator.MoveNext())
    {
    Autodesk.Revit.Elements.Room tmpRoom = elementIterator.Current as Room;


    if (null != tmpRoom && null != tmpRoom.Boundary)
    { .....do something
    }
    }
    }

    Any Idea why it is throwing the above mentioned error? It is happy to run on the individual files but doesnot run when two files are open or run on host file.

    Many Thanks in anticipation.

    regards

  10. #10
    I could stop if I wanted to
    Join Date
    2006-09
    Posts
    259
    Login to Give a bone
    0

    Default Re: Change Shared Parameters in linked file Rooms

    Please ignore my above post. I figured out what the problem was.

    regards

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 2008-11-02, 01:23 PM
  2. rooms, Schedule keys, shared parameters & tags
    By sonya in forum Revit Architecture - General
    Replies: 5
    Last Post: 2008-09-18, 01:33 PM
  3. Schedules, Linked Files and Shared Parameters
    By ron.sanpedro in forum Revit Architecture - General
    Replies: 0
    Last Post: 2008-06-06, 08:50 PM
  4. Schedule Rooms from Linked File
    By sfaust in forum Revit Architecture - General
    Replies: 7
    Last Post: 2006-07-08, 07:29 PM
  5. Shared parameters file loading
    By sifuentes in forum Revit Architecture - General
    Replies: 3
    Last Post: 2005-02-04, 04:20 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
  •