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

Re: Performing long running background computations using Idling event

$
0
0

>> Anyway, it works now

    

Brilliant! Congratulations. So, what is your final solution? Idling event without SetRaiseWithoutDelay + Poke? Is the full code provided somewhere, e.g., GitHub? Thank you!

    


Re: Flip Baseline Dimension Direction

Re: Performing long running background computations using Idling event

$
0
0
I'm going to do some more testing first, and I'll share it shortly. Thanks!

NWCOUT command in Revit

$
0
0

I am using `accoreconsole.exe` to run a script file on .dwg files to automate the export of NWC files. Is there an equivalent tool for Revit? My goal is to generate NWC files from RVT files without manually opening Revit. For Civil 3D, I achieve this using `accoreconsole.exe`. How can I accomplish this in Revit?

Re: Performing long running background computations using Idling event

$
0
0

@cdiggins  escreveu:

No it doesn't, you can try it for yourself using the Bowerbird scripting solution. What happens is that you get a few messages and then it stops sending Idle events. So work inside of the queue, remains unprocessed.


I tested an standalone plugin and works fine without PokeRevit, I use the BackgroundProcessor in the code: https://github.com/ara3d/revit-background-processor. The Idling event never stops.

 

Don't know what process you are running the in Idling, I only tested with Thread.Sleep and still triggers normally. I tested with a 1 second delay, which makes Revit really slow/laggy, and it works fine with Revit minimized/unfocused.

 

 

 

 

Re: BoundingBoxIntersectsFilter with linked model

$
0
0

Hi @Pei_LiuQ5B9P,

 

This is tricky, I solved it a couple of years ago with a lot of testing.

First advise is to print out the points used for the outline and see where they are located inside the llinked file, will it clash with anything and does it correctly represent the elements in the host file (untransformed).

 

I ended up using a Solid (SolidUtils) and generating 2 directshapes (to visualize it) one transformed (for the link) and one normal (to check if host elements positions were correctly taken.)

 

It might be off due to: The min/max coordinates from the BoundingBoxXYZ box are propably not representing the viewed element. See it's documentation ("Coordinates determined by it's transform"), this will also depend on how the BoundingBoxXYZ is retrieved.

So I ended up using the Box transform to edit the min/max point. (because the box is always aligned with the x/y, using the Transform.origin to correct the min/max would be enough)

 

Using BoundingBoxIntersectsFilter is correct, but not enough. (btw Inverse of the Linkinstance transform is correct to use)

Using BoundingBoxIntersectsFilter is only usefull to reduce the elements to check for interference, after this you actually need a Solid of the host element to detect actual intersecting elements in the link.

 

Use ElementIntersectsSolidFilter for this, with a inverse transformed solid of the host element

Use SolidUtils.CreateTransformed to create a transformed solid of the host solid element

 

First using BoundingBoxIntersectsFilter  and then ElementIntersectsSolidFilter speeds up the addin as the elements BoundingBox is fast.

 

Hope it makes sense...

- Michel

 

ps. My own intersection detect with a link went from 30min to seconds with this optimalization.

Also, with the Outline creation I always take a little extra (a Fuzz) to make sure it doesn't just miss something.

Re: Error hiding DWG categories using Revit API

$
0
0

Hi @emaguilera,

 

Maybe update the post with the correct code giving the error?

Maybe the override includes a pattern, which can't be applied to a import category?

And if only some sub-categories give a error, print their name/id and inspect it and see what's different about it.

 

Ps. a "better" way to retieve import top-category is by using it's Id.

with this code "if (cat.Name.EndsWith(".dwg", StringComparison.OrdinalIgnoreCase))" you could miss imports as the main import category can be renamed and ".dwg" removed (or dxf?)

 

I get the ID of all top categories, and all with a Id above 0 are imports, as top categories are all builtin categories with negative id's.

Re: Retrieve level from element

$
0
0

Hi @MuirEng ,

 

In Revit where the level "hides" is different between categories, even family types (facebased, levelbased etc) and between how elements are hosted (workplane a floor or level) and even between Revit versions.

 

The Dynamo node will propably have a extensive code behind it checking for the family placement type and some categories and using certain builtinparameters based on those (and more) conditions.

 

I've tried to built a global util that can read the level from any element but doesn't always come up with the correct Level if any.

Some parameters return a ElementId as host (which can be a level) but some only return a text value, with the prefix "Level : " (also depending revit version)

 

Use RevitLookup to inspect which parameters read out the level, specially if you are only concerned about one family category. If lucky the LevelId property of element will do it, else there are several parameters like:

- SCHEDULE_LEVEL_PARAM

- FAMILY_LEVEL_PARAM

- INSTANCE_FREE_HOST_PARAM

- HOST_ID_PARAM

- Etc...

 

- Michel


Re: Unable to generate rebar (Revit 2024)

$
0
0

Dear longt61

Thank you for your response. By focusing on the part you mentioned and making the necessary corrections, I was able to successfully generate the rebar model! I'm still considering how to define the centerline of the rebar, but it looks like I can move on to the next phase. Thank you very much.

Get the curves constructing a conduit fitting path

$
0
0

Hello 

I'm trying to get the path of the conduit fitting by reading the center line geometry.

There is a way to do this in LookUp.

MustafaSalaheldin_0-1728635401660.png

I followed the same logic:

foreach (FamilyInstance fitting in fittings) { GeometryElement geomElem = fitting.get_Geometry(options); LocationPoint? lp = fitting.Location as LocationPoint; IList<ElementId> centerlineIds = fitting.GetDependentElements(new ElementCategoryFilter(BuiltInCategory.OST_ConduitFittingCenterLine)); StringBuilder sb = new StringBuilder(); foreach (ElementId centerlineId in centerlineIds) { sb.AppendLine(centerlineId.ToString()); Element? curve = doc.GetElement(centerlineId); if (null != curve) { IEnumerable<GeometryObject> curves = curve.get_Geometry(new Options { IncludeNonVisibleObjects = true, ComputeReferences = true }); foreach (GeometryObject obj in curves) { TaskDialog.Show("Revit", "curve found"); } } } }

First, I access all the instances of the Conduit Fittings in the model through element collector, then get their geometries. Using GetDependentElements I can reach the conduit fittings centerlines, which were supposed when I read their geometries (as done in LookUp) is to get the IEnumerable of the composing Arcs and Lines.

In line 20 of my code, I tried to cast to GeometryElement/GeometryObject/IEnumerable<GeometryObject> but they all return no objects.
Any ideas?

Re: Get the curves constructing a conduit fitting path

$
0
0

Hi @Mustafa.Salaheldin 

 

    I'm feeling proud to reply your query, Since you're one of the prime contributors in Autodesk Forums. You have written everything correct I have made small correct by adding View to options on extracting curves. Kindly check the below code snippet for additional reference.

 

Reference Code

 

IEnumerable<GeometryObject> curves = curve.get_Geometry(new Options { IncludeNonVisibleObjects = true, ComputeReferences = true, View=doc.ActiveView });

 

 

Hope this will Helps 🙂

 

Reloading family symbol fails for the second time

$
0
0

Hi all,

I have a problem with (re)loading a family symbol.

// FamilySymbol ophalen vanuit familyName en familytype name fs = new FilteredElementCollector(doc) .OfClass(typeof(FamilySymbol)) .Cast<FamilySymbol>() .FirstOrDefault(x => x.FamilyName == familyName && x.Name == familyTypeName); CustomFamilyLoadOptions load_options = new CustomFamilyLoadOptions(); // Als niet aanwezig is dan inladen if (fs == null) { if (!doc.LoadFamilySymbol(familyPath, familyTypeName, load_options, out fs)) { TaskDialog.Show("Error", "Er gaat iets mis met het inladen van de family."); fs = null; } } else if(fs != null) { // content versie xml ophalen string contentVersieXml = selectedFileData.ContentVersie.Replace("Contentversie: ", ""); // Contentversie uit symbol halen string contVersieFamily = fs.LookupParameter("NLRS_C_content_versie")?.AsString(); if(contentVersieXml != contVersieFamily) { bool result = doc.LoadFamilySymbol(familyPath, familyTypeName, load_options, out fs); if (!result) { TaskDialog.Show("Error", "Er gaat iets mis met het (her)inladen van de family."); fs = null; } } }

 

When I use the debug function, the first familysymbol i try to reload is reloading well.

The parameters are change and everything is fine.


The second family type that I try reload fails, the   result is true but the IFamilyLoadOptions doesn't activate.

 

Here is my IFamilyLoadOptions, the first time the debug is writing this line:
OnFamilyFound _ FamilyInUse: True - overwriteParameterValues True"

 

The second time there is no debug.

/// <summary> /// Methode hoe de family ingeladen moet worden. /// Als family gevonden wordt dan overschrijft de family de parameters. /// Als Shared family gevonden worden de subcomponenten ook overschrijven. /// </summary> [Transaction(TransactionMode.Manual)] public class CustomFamilyLoadOptions : IFamilyLoadOptions { public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues) { // Als de familie al in gebruik is, beslissen we hier of we deze willen overschrijven of niet. // In dit voorbeeld zullen we de familie altijd overschrijven, zelfs als deze in gebruik is. overwriteParameterValues = true; Debug.WriteLine($"OnFamilyFound _ FamilyInUse: {familyInUse} - overwriteParameterValues {overwriteParameterValues}"); return true; } public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues) { // Als een gedeelde familie wordt gevonden, kunnen we hier beslissen of we deze willen laden of niet. // In dit voorbeeld zullen we de gedeelde familie altijd laden, zelfs als deze al in gebruik is. source = FamilySource.Family; overwriteParameterValues = true; Debug.WriteLine($"OnSharedFamilyFound _ sharedFamily: {sharedFamily} - familyInUse {familyInUse} - source {source} - overwriteParameterValues {overwriteParameterValues}"); return true; } }

 

I found this example in the SDK:

RevitSdkSamples/SDK/Samples/FamilyParametersOrder/CS/SortLoadedFamiliesParamsForm.cs at master · jeremytammik/RevitSdkSamples (github.com)

 

@jeremytammik is there a specific reason that this example is creating a temp file?

 

KG 
Jan Willem

Re: Reloading family symbol fails for the second time

$
0
0

I did not read all your code.

   

However, just looking at this line:

   

fs = new FilteredElementCollector(doc)

  

I would assume that the resulting variable fs will never be null, even if the resulting collection is empty. If so, that might explain why the following statement will never be true, and the code in the if-scope will never execute:

   

else if(fs != null)

  

I would suggest always running your dubious code in the debugger to step through it line by line and see what happens.

    

Re: Transforming of points

$
0
0

Thanks for the reply...Link file and the electrical file share the same basepoint and trure north angle.. Even after transforming the points remain same..The building is tilted a bit but rooms in the building are normally placed. So the poitns are not getting placed correctly.

Re: NWCOUT command in Revit


Re: Reloading family symbol fails for the second time

$
0
0

Thanks for the response @jeremy_tammik 
The fs started as : FamilySymbol fs = null;

 

That's the weird thing, the result is true.

 

jwvanasselt_0-1728647335960.png

 


But the IFamilyLoadOptions is not activated. Is that because the modify date of the family isnt change?

Re: Get the curves constructing a conduit fitting path

$
0
0

@Mohamed_Arshad Thanks mate, and I appreciate your nice words. Adding the view did the trick. Sometimes you need to refresh your memory and sometimes you are busy with other stuff. 😅
But thanks anyway.

Re: Transforming of points

Re: Get the curves constructing a conduit fitting path

Re: Transforming of points

$
0
0

I wonder the reason you created the method TransformPoint instead of using the Transform.OfPoint, pretty sure that does the same thing.

 

XYZ location = linkInstance.GetTotalTransform().OfPoint(locationPoint.Point);

 

There are the Transform.OfVector as well that is used for vector, basically the origin is not used in the calculation only the rotation.

 

Viewing all 67020 articles
Browse latest View live


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