PDA

View Full Version : Linking CAD Files via API



awhite343
2006-11-06, 05:27 PM
All:

I've done some searching on this forum (and others) and can't find much on this topic. I've played around for a couple of days and can't quite figure it out, so I'm coming to the experts. Is it (currently) possible to link CAD files into the active Revit file via the API?

Basically, what I want to do is the following:

1. Ask the user for a file name on their computer/server (done)
2. Create a drafting view (done)
3. Rename the drafting view and title on sheet properties (done)
4. Link in an external CAD file, with preset parameters (here's my problem)
5. Add drafting view to sheet, based on drafting view name (will do this if #4 is possible).

I know #4 can be done through the journal file, but I can't seem to get the right coding through the API.

Thanks in advance,
Aaron

Danny Polkinhorn
2006-11-07, 06:36 AM
Sorry, #4 isn't possible with the API as you've suspected.

awhite343
2006-11-07, 02:31 PM
Danny (and others):

Thanks for the quick response. At an intermediary step, do you know if it's possible to access linked files that are already in the model? For example, if I have a CAD file that is linked into "View A" (and into that view only), would it be possible to either move or copy that linked file into another view?

It seems that it should be possible since the already linked file as a Autodesk.Revit.Elements.Instance object and I ought to be able to duplicate that instance, but I can't get at the element...

Thanks again,
Aaron

Danny Polkinhorn
2006-11-07, 07:07 PM
Aaron,

It is possible to grab the element from the view using the Application.ActiveDocument.ActiveView.Elements element set, but once you've obtained it, there's very little you can do other than determine the name of the drawing (which is read-only).

Unfortunately, it's not an "Instance", it's an Element. Instances are for families and groups. You can place new Instances of families and groups, but they haven't exposed much functionality for additional model elements other than walls.

Sorry, again. It looks like your only choice is journal files.

GuyR
2006-11-07, 07:42 PM
Your other option which is way more complicated is using sendkeys to simulate keypresses. As long as the user has a keyboard shortcut for loading a DWG then that would work.

http://msdn2.microsoft.com/en-gb/library/system.windows.forms.sendkeys.aspx

HTH,

Guy

ps: Personally I'd avoid loading detail DWG's directly into projects. Put them in a detail family or even better explode in a detail family. add notes in a detail view and then save the detail view. Then you just load in the detail view when needed. bye bye DWG's......

awhite343
2006-11-16, 09:22 PM
Afternoon all:

This is just a quick note to let you know that we've confirmed through the ADN that this is not currently possible through the API. It has been logged as an issue/wishlist item.

Thanks for the help,
Aaron