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

Re: Revit crashing when I am writing some code in ComponentManager_UIElementActi

$
0
0

Dear Nitin,

 

Welcome to Revit API programming!

 

To get started with the Revit API, I suggest that you first of all take a look at the getting started material and work through the step-by-step instructions provided by the DevTV and My First Revit Plugin video tutorials:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#2

 

That will explain all you need, including the answer to your question.

 

For a quick start, you can also check out the hello world examples in the developer guide:

 

http://help.autodesk.com/view/RVT/2018/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Introduction_Getting_Started_Walkthroughs_html

 

A slightly more complex answer to your question is this:

 

All calls to the Revit API require a valid Revit API context:

 

 

Such a context is not provided by the UIElementActivated.

 

Therefore, you cannot use the Revit API there at all, and consequently not start a transaction either.

 


Re: CreateViaOffset(CurveLoop original,IList offsetDists,XYZ norma

$
0
0

Dear Stephen,

 

Yes, they suggest using a moderate percentage of the wall thickness, I believe, e.g., 10-20%. I guess that for your needs, 110-120% is required. They also say that they tested it that way, and it worked well, offsetting both inwards and outwards. The sample code that they provided was extracted from some internal Revit module and is thus not present in the SDK nor restricted to using the public API. It just shows an example of using the method, regardless of where the input comes from.

 

I'll try out this percentage thingy on your sample models and see how I fare.

 

I wish you a pleasant time during your absence in the next few weeks.

 

Cheers,

 

Jeremy

  

Re: CreateViaOffset(CurveLoop original,IList offsetDists,XYZ norma

$
0
0

Jeremy I forgot to mention I had chance to examine your latest code up date with the intention of identifying why there are 11 wall elements but only 10 thicknesses but the results I have obtained are as follows: 

normal
11 curves with lengths 10.02,6.04,4.11,5.58,.33,8.69,3.28,.16,3.44,.82,2.46 and
11 thicknesses 1.08,1.08,1.08,.76,.1,.43,.43,.1,.1,.1,1.08
-normal
11 curves with lengths 10.02,6.04,4.11,5.58,.33,8.69,3.28,.16,3.44,.82,2.46 and
11 thicknesses 1.08,1.08,1.08,.76,.1,.43,.43,.1,.1,.1,1.08
 
Regards
Stephen

Re: FindInserts what does includeShadows flag do?

Re: Cannot get rebar number

$
0
0

I met the matter too.Do you have got the solution?

Python - Numpy

$
0
0

Hi All,

 

I am using pyrevit to create some plugins for revit, so I am using python not CSharp or ....

I want to import numpy package.

At first it was giving me this error that "no module named numpy". So I found out that IronPython is not compatible with CPython packages. 

In order to use numpy you have to use CPython and in order to that you need to put one line of code at the begining of your script which is:

#! python3

 

When I add this line not only it doesn't recognize numpy, but it also doesn't recognize __revit__ and .... anymore, it does recognize some other things like (math or winform or array, os and ...)

Any help would be much appreciated.

 

Thanks,

Dave

 

call out

$
0
0

I am trying to find if a view contains a call out symbol but couldn't find a way. Anyone who tried this Before or know how to do it. Thank you.

 

Re: CreateViaOffset(CurveLoop original,IList offsetDists,XYZ norma

$
0
0

Oh well how strange that I just saw ten instead of eleven. That prompted me to list those numbers in the debug output.

 

Anyway, I tried to followed the devteam suggestion of using a percentage instead of a fixed additional offset, and it did not work for me at all. I tried both 110%, which would suit your needs, and 10%. In both cases, it still trows the InvalidOperationException saying 'loop couldn't be properly trimmed.'

 

Maybe they tested on a more recent development version of Revit.

 

So, I think it might be time to step away from CreateViaOffset for the time being.

 

On the other hand, your goal is almost reached: you have the room boundary, the boundary element and the thickness, if it is a wall. From those, it is possible to create a curve loop tracing the outsides of the walls.


Re: CreateViaOffset(CurveLoop original,IList offsetDists,XYZ norma

$
0
0

Thank you for all your help Jeremy.

If you could bare with me this one last time?

I started to look at the possibility of tracing the outside of the walls several weeks ago when I was at a loss utilising CreateViaOffset.

I was finding it difficult to create the closed loop necessary, and particularly how I would achieve this were the wall thickness changes across its length.

Could you point me in the right direction, possibly some sample code that I could examine and see if I could get it to work to my requirements.

Hope you have a good festive season.

Re: CreateViaOffset(CurveLoop original,IList offsetDists,XYZ norma

$
0
0

Sure, no problem. I'll do both: bare with you and bear with you  🙂

 

I see several possible approaches, based on:

 

  • Room boundary curves and wall thicknesses
  • Room boundary curves and wall bottom face edges
  • Projection of 3D union of room and wall solids
  • 2D union of room and wall footprints 

 

The most immediate and pure Revit API approach would be to get the curves representing the room boundaries, determine the wall thicknesses, offset the wall boundary curves outwards by wall thickness plus minimum offset, and ensure that everything is well connected by adding small connecting segments in the gaps where the offset jumps.

 

Several slightly more complex pure Revit API approaches could be designed by using the wall solids instead of just offsetting the room boundary curves based on the wall thickness. For instance, we could query the wall bottom face for its edges, determine and patch together all the bits of edge segments required to go around the outside of the wall instead of the inside.

 

Slightly more complex still, and still pure Revit API: determine the room closed shell solid, unite it with all the wall solids, and make use of the extrusion analyser to project this union vertically onto the XY plane and grab its outside edge.

 

Finally, making use of a minimalistic yet powerful 2D Boolean operation library, perform the projection onto the XY plane first, and unite the room footprint with all its surrounding wall footprints in 2D instead.

 

The two latter approaches are both implemented in my ElementOutline add-in:

 

https://github.com/jeremytammik/ElementOutline

  

I mentioned it here in two previous threads:

  

   

Probably all the pure Revit API approaches will run into various problematic exceptions cases, whereas the 2D Booleans seem very fast, reliable and robust and may well be able to handle all the exceptional cases that can possibly occur, so I would recommend trying that out first.

 

I hope this makes for a nice gift to you in this festive season.

 

Happy advent!

 

Re: How can i import my material libraries by Revit API?

Re: FindInserts what does includeShadows flag do?

$
0
0

The development team replied:

 

An internal WallShadowCutoutGStep is created when 2 walls are joined, e.g., by Modify > Geometry > Join, and then a window is placed on one wall.

 

In that case, Revit will cut an opening on the other joined wall, as you can see in this picture:

  

findinserts_wall_shadow_cutout.png

 

For this API - FindInserts, here is a short demo - I try to find the Inserts on the joined wall but not the wall with the window.

 

findinserts_include_shadow.gif

  

The window instance (ID: 354965) is returned if includeShadows is true, and nothing returned for false.

 

Many thanks to Phil Xia for this detailed explanation!

 

Re: FindInserts what does includeShadows flag do?

$
0
0

Thank you for bringing light into the shadow 🙂

 

Rudi

Update family instance parameters when lookup table changes

$
0
0

Hi All,

I am currently working on a procedure to update a lookup table connected to a family and subsequently update all instances of that family. I got as far as to update the family definition with the modified lookup table and all newly placed instances of that family are drawn with regards to the new values in the lookup table.

But what with the allready placed instances? I was looking for a way to force all instances to recalculate their parameter values but I can't seem to find the right procedure. In the fora I find procedures to update parameters to change their values but nothing to recalculate the values according to a lookup table.

Can somebody point me in the right direction?

I am currently using Revit 2020 on a Windows 10 (x64) workstation.

Regards.

Wim A.

Copy Family and Type names to text parameters for all instances

$
0
0

Hi, guys! First of all, let me start with the fact that I am new to writing code in Python and working with the Revit API. In this case, I tried to create a code that takes the strings from family and type names for all family instances of certain categories and then copies them to text shared text parameters, that can be used in schedules. I am using the Revit Python shell to run the script. As you will see, I have divided the code in two sections - the second one is for the system family categories, like walls, floors, roofs, etc, that only need Type names to bo transfered, while the first is for all other categories, that need both family and type name transfered. The problem is the it all seems to work fine, but for some of the categories it simply does not give results. For instance, I do not realise why it works for walls, but not for floors, and it also does work for ceilings and not for roofs, etc. Could you please help me find what the problem is? Thanks in advance! Here is the code(also available as attatchment):


__title__= 'FamilyName\nTypeName'
__doc__= 'Transfers family name and Type name into shared parameters\n that can be used in schedules.'
__author__= 'Dani & Bimo'

# Import from Autodesk API
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory

doc = __revit__.ActiveUIDocument.Document

element_collector = FilteredElementCollector(doc).WhereElementIsNotElementType()
element_filter = ElementCategoryFilter(BuiltInCategory.OST_PlumbingFixtures.OST_Casework.OST_Columns.OST_Windows.OST_Furniture)
category = element_collector.WherePasses(element_filter).ToElements()

t = Transaction(doc, "Update Family/Type Name")

t.Start()

for instance in category:
TypeName = instance.Name
TypeNameDuplicate = instance.LookupParameter('TypeNameDuplicate')
if TypeNameDuplicate:
TypeNameDuplicate.Set(TypeName)

for i in category:
type_id = i.GetTypeId()
element_type = doc.GetElement(type_id)
family = element_type.Family
name = family.Name
FamilyNameDuplicate = i.LookupParameter('FamilyNameDuplicate')
if FamilyNameDuplicate:
FamilyNameDuplicate.Set(name)

t.Commit()

system_collector = FilteredElementCollector(doc).WhereElementIsNotElementType()
system_filter = ElementCategoryFilter(BuiltInCategory.OST_Walls.OST_Ceilings.OST_Curtain_Systems.OST_CurtainWallMullions.OST_Floors.OST_ModelText.OST_Railings.OST_Roofs.OST_Stairs)
system_category = system_collector.WherePasses(system_filter).ToElements()

t.Start()

for system_instance in system_category:
SystemTypeName = system_instance.Name
TypeNameDuplicate = system_instance.LookupParameter('TypeNameDuplicate')
if TypeNameDuplicate:
TypeNameDuplicate.Set(SystemTypeName)

t.Commit()




cannot launch revit 2020

$
0
0

i installed revit 2020 but i had some problems in dynamo so i unistalled the revit completly but when i tried to install it again it shows the revit 2020 is already installed and it showed some files to download, i dowloaded them but after finishing, i cant find revit 2020. need help

Re: Always show the same button on SplitButton

$
0
0

 

 

This was my simple solution..

splitButtonClearLoads.IsSynchronizedWithCurrentItem = false;

Re: Cannot get rebar number

$
0
0

Not really, but I have made work around. I have changed CreateRebar method output for ElementId, so I'm passing this instead of Rebar, then in CreateContainer I'm looking for rebar number using it's ID. I works that way.

Property Line

$
0
0

Hello,

I want to retrieve the border of a property which is designed by the user. Up to now, I managed to retrieve model lines or detail lines created by the user, and use their properties (XYZ, Lines, Curveloop, etc.).

Is it possible to do the same with property lines (created using "Massing & Site" tab  - "Property Line" by sketch) ?

I can retrieve the property line object, but I don't manage to retrieve its lines.

Thank you in advance.

Revit reproducibly crashes in PickPoint (minimal test case included)

$
0
0

The bug can be reproduced as follows (Revit 2020.2, but bug can also be observed in 2019):

  • open the attached file MinimalTestCase_PickCrash.rvt (any other file should work as well)
  • run the Macro PickExample.CrashMe in a 3D view. The code is really simple:
    try
    {
    	Application.ActiveUIDocument.Selection.PickPoint(ObjectSnapTypes.None, "Click on sides of view cube and then somewhere else!");
    }
    catch(OperationCanceledException) {}
  • click on any side of the view cube (e.g. "RIGHT")
  • click into the view and you should get a message box "Revit - A serious error has occurred. The current action has been cancelled. It is strongly recommended that you save your work in a new file before continuing. Would you like to save a recovery file? Yes/No"
  • clicking "No" fortunately lets you resume the session, however it looks terrible to users if something like this happens out of nowhere, especially if you are asked to save or fear data loss.
  • attaching a debugger reveals that the following exception is thrown immediately before the crash: "Exception thrown at 0x00007FF9F9FCA388 in Revit.exe: Microsoft C++ exception: ModificationOutsideTransactionException at memory location 0x00000019915081B0."
Viewing all 66917 articles
Browse latest View live


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