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

Re: HasReflection property in the Transform class?

$
0
0

Hi!

 

It is true, at least until all 3 basis vectors are orthogonal, you can also test it by checking Transform.IsConfromal property value.

 

Any valid transformation (e.g. matrix determinant is not equal to zero) can be described as a combination of translation, rotation, scaling and reflection matrices. Only reflection matrices change the handedness of a coordinate system. You can also check it: t.BasisX.CrossProduct(t.BasisY) should return t.BasisZ value. If it is so, your transform does not have reflection and determinant is positive.

 

If you change the direction of one of transform basis or swap 2 vectors (for example BasisX and BasisY) the transform will determine reflection, its determinant will become negative and BasisX x BasisY will be -1*BasisZ


Hide ribbon tab if family document active

Missing /AdWindows;component/themes/badge.xaml

$
0
0

I've been having a few different problems while trying to load a plugin into Revit. The plugin worked a few weeks ago, then I added a few things and it stopped working due to multiple problems. I'm not sure if any of them are related to the others, so I'll give you a rundown of what I've changed.

 

First I added a reference to EntityFramework. When loading the plugin in revit, it failed to find the referenced dll. I got past that by adding an assembly resolver that loaded the dll manually. That got me past a few different dll problems. Each of these are handled by a specific case.

This is how I resolved them:

if (args.Name.Contains("Microsoft.EntityFrameworkCore"))
{
	string assemblyFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Microsoft.EntityFrameworkCore.dll");
	if (File.Exists(assemblyFile))
	{
		return Assembly.LoadFrom(assemblyFile);
	}
}
//Checked for all other dlls with known issues return null;

Now that I can get the plugin to load into revit when I start it up, I hit another problem when I try to open a new project. As soon as I try to load one of the given templates (or click on the add-ins tab), I get the following exception.

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message=The invocation of the constructor on type 'Autodesk.Internal.Windows.Badge' that matches the specified binding constraints threw an exception.
  Source=PresentationFramework
  StackTrace:
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)
   at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
   at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren)
   at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate)
   at System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container)
   at System.Windows.FrameworkElement.ApplyTemplate()
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Autodesk.Private.Windows.PanelListView.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
   at Autodesk.Private.Windows.PanelListScrollViewer.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.StackPanel.StackMeasureHelper(IStackMeasure measureElement, IStackMeasureScrollData scrollData, Size constraint)
   at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
   at Autodesk.Private.Windows.PanelSetListView.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.Interop.HwndSource.SetLayoutSize()
   at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
   at DockablePaneInterop.attachPane(DockablePaneInterop* , HWND__* parent, DockablePaneProviderData paneData)
   at APIDockableView.OnCreate(APIDockableView* , tagCREATESTRUCTW* lpCreateStruct)
   at MFCFormView.WindowProc(MFCFormView* , UInt32 , UInt64 , Int64 )

Inner Exception 1:
Exception: The component 'Autodesk.Internal.Windows.Badge' does not have a resource identified by the URI '/AdWindows;component/themes/badge.xaml'.

Any ideas for why I'm getting this exception or how to fix it?

Re: Hide ribbon tab if family document active

$
0
0

Hi!

 

You can add a reference to UIFramework.dll (it is in the same folder as RevitAPI.dll)

 

Then you can control specific tab visibility:

var rc = RevitRibbonControl.RibbonControl;

var tab = rc.FindTab("<your tab name>");

tab?.IsVisible = false; // or true

It can be done in ViewActivated event handler, something like:

private void OnViewActivated(object sender, ViewActivatedEventArgs e)
        {
... tab.IsVisible = !e.Document.IsFamilyDocument; }

Re: Revit family naming different than file name

$
0
0

Dear Narveen, do you have an answer to my question below?

thank you,

Stefan

The program '[148xx] Revit.exe' has exited with code 0 (0x0).

$
0
0

Dear All,
In 2016 I wrote a small add-in for revit. Now I bought revit 2019 and I want to update the old add-in, but when I start to run the code I get the following error:

The program '[148xx] Revit.exe' has exited with code 0 (0x0).

I have seen the following link, but I guess they are something different:

https://forums.autodesk.com/t5/revit-api-forum/devtv-my-first-revit-plugin-revit-exe-has-exited-with-code/td-p/5365593

https://forums.autodesk.com/t5/revit-api-forum/cannot-start-revit-2015-for-api-debugging/td-p/4978060

http://thebuildingcoder.typepad.com/blog/2013/11/debugging-revit-2014-api-with-visual-studio-2013.html

 

 

 

Can I open the Revit 2019.1 SDK .csproj samples?

$
0
0

I just started learning C# to develop a plugin for Revit in .net and I went through the HelloWorld tutorial.

I was looking foward to be able to learn from the Revit 2019.1 SDK samples found here:

https://www.autodesk.com/developer-network/platform-technologies/revit

 

How can I open the csproj samples files ?

 

I want to be able to open the csproj files of the Revit 2019.1 SDK samples to learn from the addins created. Can I do that?

When I try to open them I get an error message:

"The imported project "C:/Revit 2019.1SDK\Samples\Events\<name of sample I want to open>\CS\VSProps\SDKSamples.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\Revit2019.1SDK\Samples|Events\<name of sample I want to open>\CS\<name of sample I want to open>.csproj"

(see attached png).

 

In fact, I can't find the SDKSamples.targets

 

Any help would be appreciated.

Re: Insulation in FabricationPart doesn't get intersected through ReferenceInter

$
0
0

Hi JeffYao,

     I created a duct (Height:305mm, Width:305mm) with 25mm insulation thickness in Revit 2018 accroding to your attachment, and codes as below:

var doc = commandData.Application.ActiveUIDocument.Document;
var referenceIntersector = new ReferenceIntersector(new ElementIsElementTypeFilter(true),FindReferenceTarget.All, (View3D)commandData.Application.ActiveUIDocument.ActiveView);
var refInContextlist = referenceIntersector.Find(new XYZ(0, 0, 0), XYZ.BasisZ);

 I found six data in refInContextlist:
    1. Proximity = 9.34219160104987
    2. Proximity = 10.342847769028872
    3. Proximity = 9.34219160104987
    4. Proximity = 10.4248687664042
    5. Proximity = 9.26017060367454
    6. Proximity = 9.26017060367454
so:
    (9.34219160104987-9.26017060367454)*304.8 = 25mm.

It means insulation in FabricationPart could get intersected through ReferenceIntersect.
I advise that you could use Find() function not FindNearest() function to find project point in insulation. I will inform Revit team to investigate why the closest data is not in the first place.

Wish it is helpful for you :)

Best Regards
Jim Jia


Re: HasReflection property in the Transform class?

$
0
0

Thanks for the explanation aignatovich.  Quite helpful.  My lingering questions are related specifically to the implementation details of the HasReflection property and how the Revit API makes that decision.  Think I may have just found the answer though.

 

The api documentation states, "Reflection transformation changes the handedness of a coordinate system."

 

So that seems to be the answer.  HasReflection seems to just be an evaluation of whether or not the associated Transform matrix results in a change to the handedness of the coordinate system.  But if anyone knows otherwise, please correct me.

 

Re: Class cannot be found in the addin assembly VB .net

$
0
0

Yup, that would be the reason.

 

I would recommend looking at C# or Python instead. They are both fine.

 

Good luck and have fun!

 

Re: The program '[148xx] Revit.exe' has exited with code 0 (0x0).

$
0
0

Your add-in is probably doing something wrong. What does it do, and how?

 

Re: Missing /AdWindows;component/themes/badge.xaml

$
0
0

No idea whatsoever why you see these messages. I never heard of them.

 

Yes, I do have an idea to fix it, and I use it myself all the time.

 

Whenever anyone shares an add-in with me, I do not try to adapt it to run on my system.

 

Instead, I use the Visual Studio Revit add-in wizard to create myself a new add-in skeleton, all automatically set up and ready to run:

 

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

 

Then I just copy the new code into its external command and external application modules and I'm set with no hassles.

 

Cheers,

 

Jeremy

 

Re: Revit family naming different than file name

How to filter elements through the Tab?

$
0
0

The title is maybe a little confusing. For example, I had a List<Element> elements. As shown in the figure below, the System Tab owns various element types: HVAC type, Fabrication type, Mechanical type, Piping type, Electrical type. I need to classify the elements list by these types. Is there any method to implement this? Revit.png

 

 

 

Re: How to change the "ViewSection" range ?

$
0
0

Thank you!
Your method can be completed


Re: Can I open the Revit 2019.1 SDK .csproj samples?

$
0
0

Hi ,

 Copy the VSProps folder(D:\revit sdk\Samples)  to Autoupdate folder(D:\revit sdk\Samples\Events\AutoUpdate\CS) and try to open the Autoupdate project file.

Screenshot (24).pngScreenshot (25).png

Re: The program '[148xx] Revit.exe' has exited with code 0 (0x0).

$
0
0

Hi !

It has a link for going online and import doors. When I debug it, I get no errors, 

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Single Wall finish

$
0
0

Dear Forum Members,

If I want to change the color of a selected  wall I can do it via

doc.ActiveView.set_ProjColorOverrideByElement(     ids, color );

Using this the color of only the single wall changes without other walls being modified.

In the same manner how do I change the finish of the selected wall without modifying other walls.

Thanks & Regards

Sanjay Pandey

Re: How to filter elements through the Tab?

$
0
0

Use FilteredElementCollector to collect elements and get the type of the elements and with the help of the type classify the elements

 FilteredElementCollector Collector = new FilteredElementCollector(doc).WhereElementIsNotElementType();
                IList<ElementId> all_eids = Collector.ToElementIds() as IList<ElementId>;

                IList<ElementId> mech_ids = new List<ElementId>();
                IList<ElementId> elec_ids = new List<ElementId>();
                IList<ElementId> HVAC_ids = new List<ElementId>();
                IList<ElementId> piping_ids = new List<ElementId>();
                IList<ElementId> fabrication_ids = new List<ElementId>();

                foreach(ElementId eid in all_eids)
                {
                    Element e = doc.GetElement(eid);
                    Type T = e.GetType() as Type;
                    if(T.Name.Contains("Mechanical"))
                    {
                        mech_ids.Add(e.Id);
                    }
                    if(T.Name.Contains("Electrical"))
                    {
                        elec_ids.Add(e.Id);
                    }
                    if(T.Name.Contains("HVAC"))
                    {
                        HVAC_ids.Add(e.Id);
                    }
                    if(T.Name.Contains("Piping"))
                    {
                        piping_ids.Add(e.Id);
                    }
                    if(T.Name.Contains("Fabrication"))
                    {
                        fabrication_ids.Add(e.Id);
                    }

                }

Re: Single Wall finish

$
0
0

Does the wall finish correspond to an individual Revit database element? If so, you could presumably pass in it element id to the same method you use for the wall. You should be able to determine that with RevitLookup.

 

Cheers,

 

Jeremy

 

Viewing all 66715 articles
Browse latest View live


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