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

Re: Save input data

$
0
0

Hi,

 

if by “this data” you mean the data you saved in element using Extensible storage, and assuming by saying “from .cs file” you mean in your code because the data stored using extensible storage is stored in revit element and not your .cs file. Now, in your code, You can get it by retrieving that element in which you stored the data and using get entity the data can be retrieved from that element. 

hope this helps!

cheers,

Vish K.


Re: Opening Linked Model Hosted On BIM360

$
0
0

Hi Rudolf,

 

That's a great point indeed. Thanks for the heads up. Fortunately for this use case it'll be used only on English computers so I shouldn't have to worry about localization.

 

Thanks,

Brandon

Re: Getting FilterRule of ParameterFilterElement with API2020(c#)

$
0
0

What has changed is that there is now an additional layer in between representing the two possibilities of 'AND' and 'OR' FilterSets.

 

so your previous 

rules = pfe.GetRules();

 

would have to change in order to first get the filters contained within, then you can loop over them

ElementLogicalFilter elf = pfe.GetElementFilter() as ElementLogicalFilter; IList<ElementFilter> efs = elf.GetFilters(); rules = new List<FilterRule>(); foreach (ElementFilter ef in efs){ ElementParameterFilter epf = ef as ElementParameterFilter; rules.AddRange(epf.GetRules()); }

 

Re: Revit API Roadmap

Re: REVIT LT 2017 - All text disappears in PDF print.

$
0
0

@l.caruana95

I have just had the same problem with Revit 2020. Did you find a solution?

Direct Integration between Civil3d and Revit

$
0
0

Can we capture the civil3d coordinates directly to a revit model using automation  serra.?

 

CloseXML Write To Excel FileNotFoundException

$
0
0

Hello,

 

I'm trying to export some information to Excel by using the ClosedXML. I've installed it using the NuGet package in the Visual Studio. However, whenever the export function is called, I get the following error:

 

System.IO.FileNotFoundException: Could not load file or assembly 'ClosedXML, Version=0.95.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

 

I've workaround it by copying the ClosedXML dlls into the C:\Program Files\Autodesk\Revit 2020 folder.

ClosedXML.dll

DocumentFormat.OpenXml.dll

ExcelNumberFormat.dll

System.IO.FileSystem.Primitives.dll

System.IO.Packaging.dll

 

But wondering why this happens, and I am seeking a better solution rather than copying the files.

 

Any help is much appreciated. Thanks

 

Re: CloseXML Write To Excel FileNotFoundException

$
0
0

Hi,

 

I can see that at least two Autodesk add-ins use System.IO.FileSystem.Primitives.dll, these are the "FabricationPartBrowser" and "P&ID Modeler" add-ins.

Maybe their file version differs from the one ClosedXML refers to?

 

As you know, the first add-in to be loaded, determines the dll version.

So if another add-in uses a different version than you, that's a problem.

Add-ins are loaded in alphabethical order, I also think that these ones shipped with Revit will be loaded earlier than third-party ones.

 

There is a solution by merging the dlls into a single one:

https://forums.autodesk.com/t5/revit-api-forum/reference-external-dll-conflicts-ilmerge-fody-etc/m-p/9624575

 

 

Revitalizer

 


Re: Save input data

$
0
0

Yes, I manage easily to retrieve this data stored in element using ExtensibleStorage in my code.

What I want to do is to retrieve this data in my view model (the code that is used for my WPF window). I want to display this data in textblocs of my WPF window, for instance.

I've read that Revit classes should not be used within the view model:

https://mathcadbimthingy.wordpress.com/2017/01/25/view-viewmodel-ing-for-your-wpf-windows-revit-api-with-wpf-series-33/

Is that right ? If yes, what should I do ?

(Sorry I'm not an IT, I have basics knowledge in programming…)

Sincerely.

Re: Save input data

$
0
0

Once you retrieved your data, you can store wpf textbox or any item value by first setting its modifier settings from private to public or whatever you want to so you can access that settings in your code to set the value.

set the values before form.showdialog and make sure to refresh the form. 

Cheers!

Vish. k.

Re: Execute or raise command in Revit from another Application (WinForm) / .EXE

$
0
0

There have been many discussions regarding this.

 

I've in the past considered FileWatcher and Pipes but I've found recently an interesting way. I've included the solution as a zip file.

 

This may have been suggested before and I don't know of any limitations yet regarding message length etc. The mechanism included in the solution is adapted from:

https://www.codeproject.com/articles/19570/inter-process-communication-with-c

 

The mechanism:

  1. Open and hide a form during OnStartup. In that form override WndProc to receive messages
  2. In the non-revit app find the hidden window by a GUID name and send it a message
  3. Within WndProc of the form receive the message WM_COPYDATA and raise an ExternalEvent in Revit to process the message.

 

The solution contains an ExternalCommand for picking an element and sending it's ID to the non-Revit app and an ExternalApplication that receives the messages from the non-Revit app. i.e.

 

Step 1 (Revit to non-Revit):

 

200805a.png

Step 2 (non-Revit to Revit):

 

200805b.png

 

I'm sending a string but if you can send a string then perhaps you can send serialised object etc.

 

This could also be useful for running a progress bar in it's own process without having to call DoEvents.

In IExportContext.OnInstanceBegin, InstanceNode has invalid SymbolId

$
0
0

I am using IExportContext to export Revit models geometry. We just encountered a new case where some instance nodes report invalid symbol ids. That is:

 

node.GetSymbolId() == -1

 

If I return RenderNodeAction.Proceed from OnInstanceBegin, it goes directly to OnInstanceEnd without ever calling OnPolymesh(). What would cause this issue? How can we work around it? This issue is causing some elements being absent from the final exported geometry.

Re: Execute or raise command in Revit from another Application (WinForm) / .EXE

$
0
0

Thanks a lot   !

 

We've been looking for just the direction and you delivered us a golden gift ! 

 

It's absolutely perfect, thanks for the sample and your time !

 

TeamDev

Re: Trim/Extend Element Method ?

$
0
0

I also want to know further about this issue. I am currently interested in extending one Line element to another.

For example I have 2 simple lines such as shown below:

 

XYZ ptA = XYZ.Zero; XYZ ptB = new XYZ(10, 0, 0); XYZ ptC = new XYZ(5, 5, 0); XYZ ptD = new XYZ(5, 10, 0); Line line1 = Line.CreateBound(ptA,ptB); Line line2 = Line.CreateBound(ptC,ptD);

 

 How can I extend line2 so it touches with line1? I tried looking at the SDK Documentation and the revitapidocs for Lines, Curves, XYZ and I still have no clue. I find something called TrimExtendCurves Method but don't know how to use it properly, if it is limited to Rebar elements only or if it is even relevant with the current issue at all.

Re: Save input data

$
0
0

Okay ! Indeed, my mistake was to initialize values manually. I initialized textblocs values from my code, and now it works !

Thank you for your help.

Sincerely.


Disable Print button

$
0
0

Hi All,

 

I want to disable print button in Revit whenever it is launched to restrict my students from using it. Is it possible to achieve this using Revit API maybe with IsCommandAvailable ?

Re: Disable Print button

$
0
0

Hi,

 

you could register for the Application/ControlledApplication.DocumentPrinting event.

 

When this event is triggered, you may call the documentPrintingEventArgs.Cancel() method to stop the printing process.

 

 

Revitalizer

Re: Trim/Extend Element Method ?

$
0
0

 
you can get the intersection of two lines P(I), and check the distance of between intersection points and each end point of the line you want to extent. Whichever is short distance, you can replace that endpoint it by P(I) in create line bound.

you’ll get the desired extension. 
  same concept can be applied for walls and columns, I am not really sure what geometry element they are but you can use RevitLookup to see the geometry type and create the logic.

 


cheers!

Vish. K.

Place column at grid interection

$
0
0

Hi,

I trying to create column at gird interection, expection show"There are identical instances in the same place. This will result in double counting in schedules." please  check attachments below. whats wrong with my code? any helps will be apprecitated.

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using System.Runtime.InteropServices.WindowsRuntime;

namespace point
{
[Transaction(TransactionMode.Manual)]
public class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;

var gridlist = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Grids).OfClass(typeof(Grid)).ToList();

List<Curve> curelist = new List<Curve>();
List<XYZ> inpoint = new List<XYZ>();

foreach (Grid grid in gridlist)
{
curelist.Add(grid.Curve as Curve);
}

for (int i = 0; i < curelist.Count; i++)
{
IntersectionResultArray arrresult = null;
SetComparisonResult setresult = curelist[0].Intersect(curelist[1], out arrresult);

if (setresult != SetComparisonResult.Overlap)
{
throw new InvalidOperationException("no intersect");
}
if (arrresult == null || arrresult.Size != 1)
{
throw new InvalidOperationException("no intersect or more than one ");
}
if (setresult==SetComparisonResult.Overlap&&arrresult.Size==1)
{
XYZ point = arrresult.get_Item(0).XYZPoint;
if (inpoint.Where(x=>x.IsAlmostEqualTo(point)).Count()==0)
{
inpoint.Add(point);
}
}

var column = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Columns).Where(x => x.Name == "457 x 475mm");
Element ele = column.FirstOrDefault();
FamilySymbol fs = ele as FamilySymbol;

Level lv = doc.GetElement(new ElementId(13071)) as Level;
Transaction tx = new Transaction(doc, "create column");
tx.Start();
if (!fs.IsActive)
{
fs.Activate();
}
foreach (XYZ p in inpoint)
{
doc.Create.NewFamilyInstance(p, fs, lv, Autodesk.Revit.DB.Structure.StructuralType.Column);
}
tx.Commit();

 

}

return Result.Succeeded;
}
}
}

Re: Place column at grid interection

$
0
0

just like how Revit complains, you have identical points for placing columns. Possible reason behind: keep indexing the same pair of curves?

jshial_0-1596705137597.png

 

Viewing all 66900 articles
Browse latest View live


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