Quantcast
Channel: All Revit API Forum posts
Viewing all 66677 articles
Browse latest View live

Re: Cant understand how external event works.

$
0
0

Thank you so much, I dint Understand this initially I had to read about concepts of external events and how it works to make it work, thanks for pointing me in the right direction.! 

 

I am attaching the code here just in case if you or anybody else can show me a shorter way of doing this.

 

 

 

namespace Skp2Rvt { [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class SKP_Importer_command : IExternalCommand { public static Document doc = null; public static UIApplication application = null; public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { IExternalEventHandler handler_event = new SkpImporter_EventHandler(); ExternalEvent exEvent = ExternalEvent.Create(handler_event); application = commandData.Application; doc = application.ActiveUIDocument.Document; var form = new Form1(exEvent); form.Show(); return Result.Succeeded; } } public class SkpImporter_EventHandler : IExternalEventHandler { public void Execute(UIApplication uiapp) { UIDocument uidoc = uiapp.ActiveUIDocument; if (null == uidoc) { return; // no document, nothing to do } Document doc = uidoc.Document; using (Transaction tx = new Transaction(doc,"My event")) { try { Transaction trans = new Transaction(doc, "Import SKP file"); trans.Start(); var optionSKP = new SKPImportOptions(); var ActiveView = doc.ActiveView; var file = Form1.FileLocation; var SKP_File_Id = doc.Import(file, optionSKP, ActiveView); var SKP_file = doc.GetElement(SKP_File_Id); var list = new List<ElementId>(); list.Add(SKP_File_Id); uidoc.Selection.SetElementIds(list); trans.Commit(); } catch { TaskDialog.Show("Error", "Something went wrong with the import,please check the version of SKP file."); } } } public string GetName() { return "my event"; } } }

 

 


Re: Filter point based family

$
0
0

Hi,

 

1. No need to perform it on every symbol, only one per Family will do (Family types can't be different!)

2. Do you need this info for all Families in project or only used (instance placed) ones.

 

The second is easy to perform and fast, for the first the family itself should be inspected. (EditFamily )

 

- Michel

Re: Set Line weight in mm for a DetailLine

$
0
0

Hi,

 

Always think how it's done in the UI, you override the element in view.

look at View.SetElementOverrides 

 

Also here one of the 16 pens should be selected, the width's of the 16 pens can only be discovered in the UI can't be done in the API.

 

- Michel

Re: Display an image loaded in memory via the .NET API.

$
0
0

Do you just want to display an image on the screen?

Or do you actually want to load the image into the view as an ImageInstance?

In the second case, I think you will have to save the image from memory to the drive first.

 

Re: Can a pipe have multiple pipe types assigned?

$
0
0

Hi Jeremy

 

I'm really looking forward for the fix REVIT-161421 being published. Otherwise, we wont be able to publish our new feature to our customers.

Re: NewFamilyInstance(Face,Line,FamilySymbol), ArgumentsInconsistentException

Re: FBX_LIGHT_PHOTOMETRIC_FILE, absolute IES path issue

$
0
0

I had the same exact problem and it seems that setting the parameter with the FamilyManager afterward fixes the problem.

 

// The parameter's name will change depending on Revit's language FamilyParameter familyParameter = doc.FamilyManager.get_Parameter("Photometric Web File"); doc.FamilyManager.Set(familyParameter, @"C:\Users\bianc\Desktop\PIL_071451.IES");

 

If it doesn't work straight away, try to doc.Regenerate() before setting the parameter.

Re: Adding a COM refernce in class library project for Revit button

$
0
0

 

You were right. The problem was on the user machine. Uninstalled and reinstalled MS Office... now works as expected.

Thank you.

Regards

Corinne


Re: COM Exception when using Microsoft.Office.Interop.Word

$
0
0

The problem was on the user machine. After he uninstalled MS Office and reinstalled it the error disappeard. Now the add-in works as expected.

Re: Set Line weight in mm for a DetailLine

$
0
0

Thanks to you and other forum posts (https://thebuildingcoder.typepad.com/blog/2016/10/how-to-create-a-new-line-style.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+typepad%2Fthe-building-coder+%28The+Building+Coder%29)

 

I decided to create differents Line Categories then I apply them to my DetailLines. Here is my code :

 

public static void createLineStyles() { Document doc = Application.uiApplication.ActiveUIDocument.Document; using (Transaction t = new Transaction(doc, "LineStyles Creation")) { t.Start(); // Get Lines Category Categories categories = doc.Settings.Categories; Category lineCat = categories.get_Item(BuiltInCategory.OST_Lines); CategoryNameMap subcats = lineCat.SubCategories; // Create 10 Line Styles for (int i = 1; i < 11; i++) { // If Category doesn't exists if (!subcats.Contains("MyStyle" + i.ToString())) { Category newLineStyleCat = categories.NewSubcategory(lineCat, "MyStyle" + i.ToString()); doc.Regenerate(); // Set line weight newLineStyleCat.SetLineWeight(i, GraphicsStyleType.Projection); } } t.Commit(); } }

 

I need to specify line weight in mm. As this is not possible I thought about alternative solution :

 

For example : if I need to set 1mm to the line, I browse the the line weight table (1 to 16) and select the closest value to 1mm.

 

The issue I'm facing is : how to get le dimension each line weight (1 to 16) (Example : how to get the size in mm of LineWight 1)

 

Do you have a solution for this ?

 

Thanks a lot

Re: Revit API to edit Model Line Weights for a given scale

$
0
0

Hi,

 

I'm facing to the same issue.

 

Did somebody has a solution for this ?

 

Thanks in advance

Re: Set Line weight in mm for a DetailLine

$
0
0

Hi, like I said the weight applied to each of the 16 pens can't be retrieved by the API!

 

You know where to set the weights per pen/scale? else, see image below.

Depending you're addin either let the use chose a pen (1-16) like in UI or make you're own convertion table pen-width in mm, which could be/become different from project if someone changes the UI settings weights and won't match anymore.

Also depending the type of line/object and viewtype the weight can be different per scale (if setup in UI, see image)

 

Personally I would forget about the mm thing and let the user select one of the 16 pens

Or I must be something missing about you're story?

 

UI_lineWeights.png

 

- Michel

Re: Set Line weight in mm for a DetailLine

$
0
0

Hi,

 

Thanks for your support. I'll give up the idea getting the weight of line as it's not accessible via api.

 

The plugin I'm developping must design lines (in ViewSheet) with a specified line weight in mm.

Re: Display an image loaded in memory via the .NET API.

$
0
0

Hello,

 

If in the first case you mention you mean something like displaying the image on the screen outside the context of Revit or the view, like overlaying it so to speak, the no, nothing like that. I want to do something closer to the second case but without having to use ImageInstance nessecarily. I want to place the image within the view at some coordinates in such a way that it is spatialy related to the rest of the buildings/elements existing there. But I need this to be done without having to save the image in a local file, just load it to the memory when it is needed by my addin.

Going into more detail on what i've considered doing, if this is of interest, I've though of two interfaces in Revit API which appeared promising, but I hit a wall with both.

One was the DirectContext3D API, where I hopes to create a simple planar entity and use the image as a texture for the material. Unfortunately, it seems that DirectContext3D does not support textures yet. Except if I missed something, but it was also explicitly stated in this presentation: https://www.autodesk.com/autodesk-university/class/DirectContext3D-API-Displaying-External-Graphics-Revit-2017#video

The second thing that seemed promising at first was ITransientElementMaker, thinking that I could import a temporary image object through that, but then I had these problems:
First, I found almost no examples of how to use the interface (what should go in the Execute method? What types can I use? DO I need a Transcation?).
Second, I found these answers which seem quite discouraging: 
a. https://forums.autodesk.com/t5/revit-api-forum/document-maketransientelements/td-p/7774471
b. https://forums.autodesk.com/t5/revit-api-forum/display-an-overlay-image-placemark-on-revit-3d-view/m-p/8168195

Thus I am kinda out of ideas, my conundrum magnified by the fact of having a much stronger background in AutoCAD than Revit...

Ignore warning message contraints on EditFamily

$
0
0

Hi

In an opened Document, I make a loop on all FamilySymbols (isEditable = True).

For each Family, I make an myDoc.EditFamily(Family of loop)

My problem is, I'd like to Ignore warnings message of contraints.

Is it possible?

I've tested what Jeremy said here :

https://thebuildingcoder.typepad.com/blog/2010/04/failure-api.html

But, the problem is, I can't EditFamily with a transaction.Start() done before....

What can I do please?


Re: Set MaterialId of Integral Wall Sweep

$
0
0

  The sweeps were indeed created through the UI, I didn't use API for that.  I wouldn't have guessed that you need to remove and fiddle with the id and add back.  Thanks so much for the help! 

Re: ID of elements is changes when a family is opened from a project

$
0
0

no, your logic with fruits in a basket is unacceptable. Position of elements is important if there are cross-references!  It's important for me to know, for example, at which elements this Dimension is set, and I need to know if Dimension is moved from one element to other. In fact, "ElementID" was created just for this case, it's usual "database primary key".

Store the geometry information is bad idea too, because elements may move when a family is opened from a project, for example, value of "type" parameter may change when new FamilySymbols are created or changed in the project.

Create new Report?

$
0
0

Is there a way to create a new report category and new report? It looks like all the native Revit reports are .htm files stored in the Temp directory, I can mirror that, but how do I link the report into the project browser? 

 

I'm not sure if this is possible, I don't think there is a way to do this through the Revit UI, so I'm not optimistic.  How is everyone displaying information from their apps so it feels like the Revit workflow? 

 

klawson_1-1588258931419.png

 

 

 

 

Revit 2021 Version Information Issue

$
0
0

Hello,

 

UIControlledApplication.ControlledApplication.VersionBuild is returning the value that would normally be returned by UIControlledApplication.ControlledApplication.VersionNumber
Is this the expected behavior, or maybe a bug with Revit 2021?

e.g.
VersionBuild should be '20200220_1100(x64)' but it is '21.0.0.383', however they do appear to be correctly displayed in the About Autodesk Revit 2021 dialog shown below

 

Todd_Jacobs_0-1588259197744.png

Thanks,

Todd

 

Re: CAD import layer-split geometry

$
0
0

Thank you very much, this has been great help.

 

I have another issue you might be able to help with:

 

After I have retrieved the coordinates, I would like to delete the lines within that certain layer.

I have tried to doc.Delete() the Lines but they don't have and ElementId and you can't reassign them as an Element. Neither can you do that with the GeometryObject.

 

As a workaround to this I have tried to import the .dwg again without said layer, but it seems I can't retrieve the other layers' names because they don't seem to have a valid ElementId for the GraphicsStyle so they can't be queried properly.

 

Thanks again.

Viewing all 66677 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>