Results 1 to 5 of 5

Thread: connect as external program

  1. #1
    Member
    Join Date
    2018-04
    Posts
    2
    Login to Give a bone
    0

    Question connect as external program

    I want to have a program that communicate external with Revit is it possible?
    I not want to use Ribbon.

    To get Object ID from a AutoCad object I use this code before:

    Dim AcDoc As Autodesk.AutoCAD.Interop.AcadDocument
    Dim AcObj As Autodesk.AutoCAD.Interop.Common.AcadObject
    AcApp = GetObject(, "AutoCAD.Application")
    DWG = AcApp.ActiveDocument.Name
    AcDoc = AcApp.ActiveDocument
    Dim basePnt As Object
    Dim ObjID as string
    AcDoc.Utility.GetEntity(AcObj, basePnt, "Click on a object")
    ObjID=AcObj.Handle
    Msgbox("Object ID: " & ObjID)

  2. #2
    Member
    Join Date
    2015-12
    Posts
    19
    Login to Give a bone
    0

    Default Re: connect as external program

    I haven't seen programs that communicate externally with Revit and it's probably due to the same reason Revit is not so friendly when developing internal add-ins. Notice how Revit disables the ribbon bar (including the add-ins panel) when working in certain views or disables almost everything when working in sketch mode. The reason is because Revit does not like to service or give access to its database when it's not in a ready state, or it's busy doing something. Revit does not like multi-tasking. My guess is that external commands (similar to COM with Ms Office or other applications) are not possible because Revit does not guarantee a ready state to process commands from external applications.

    There is hope however. There is a clean and working solution by creating an internal add-in that places Revit in a ready state to communicate externally. If your external app is only reading data, then your internal add-in may be non-modal, and I would give it a try even though it's not guaranteed to work when Revit is caught in sketch-mode, or say in a non-graphical view (schedule). You'll have to create an external application (a client app) that communicates with the Revit add-in (a server), and the communication protocol will have to be either by exporting/importing xml/json file, or better yet instant communication through http client/server .net library. If you want to modify the Revit project (not only read element ids), then your Revit add-in needs to be modal. This is because Revit will not allow an internal app to run non-modally (yes even internal add-ins are restricted) in the background and make changes (i.e. in API terms, commit a transaction). Having said that, a modal add-in is allowed to make changes because it disable all Revit menus, and forces Revit to commit to your add-in.

    I hope this makes sense, and if doesn't, please let me know.

  3. #3
    Member
    Join Date
    2015-12
    Posts
    19
    Login to Give a bone
    0

    Default Re: connect as external program

    To make my answer thorough without making it too complex, I'm obliged to mention that non-modal add-ins (which can run in the background without being blocked by Revit) can also make changes to the Revit project/document, but achieving this is very complex and beyond the scope of what you're trying to achieve. That's why making a modal add-in is easier and more straight-forward if your add-in needs to make modifications.

  4. #4
    Member
    Join Date
    2018-04
    Posts
    2
    Login to Give a bone
    0

    Default Re: connect as external program

    Thanks for your answer

    This help a lot.

  5. #5
    Active Member
    Join Date
    2011-11
    Location
    Saint-Omer, Pas-de-Calais, France
    Posts
    58
    Login to Give a bone
    0

    Default Re: connect as external program

    You can create a COM server and use an external event to interact with Revit API. I can not explain all the stuff here because it's a lot of code, but you have to create an interface, an implementation of this interface with the ComVisible attribute at true and a ProgId, and in your Application.OnStartup method, you create an instance of your server and you put it in the ROT (Running Object Table) with the RegisterActiveObject function. Then you can call the methods of your interface from an external process. I use this approach with one of my application and it works well.

Similar Threads

  1. Replies: 5
    Last Post: 2009-07-09, 10:23 AM
  2. Start a journal file via an external program?
    By sfaust in forum Revit - API
    Replies: 2
    Last Post: 2009-06-10, 03:52 PM
  3. Editing Styles Via an External Program?
    By ewhite in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2008-05-28, 09:55 PM
  4. Accessing Revit from aan external program...
    By jose.campero in forum Revit - API
    Replies: 0
    Last Post: 2005-12-05, 09:05 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
  •