Revit 2019 API, element.CanBeHidden returning false for 2019, true for 2018

Revit 2019 API, element.CanBeHidden returning false for 2019, true for 2018

Anonymous
Not applicable
1,048 Views
11 Replies
Message 1 of 12

Revit 2019 API, element.CanBeHidden returning false for 2019, true for 2018

Anonymous
Not applicable

Hi,

 

We have an application that imports models from Tekla into Revit, via the Revit API. The application has, over the years, been migrated from Revit 2013 to Revit 2018 and I am currently updating and testing the application for Revit 2019. All looks good apart from when I try and hide objects using the Revit 2019 API (we typically hide the void cut objects). 

 

If I import a simple model using the Revit 2018 API element.CanBeHidden(view) returns true and the relevant objects are hidden (view.HideElements) without any problems. At 2019, the same imported model and objects will return false and fail to be hidden.

 

I reviewed the ref help and forum and cannot see any thing that indicates an issue or a revised way of working, although I may well be missing something so any feedback would be greatly appreciated.

 

Many thanks

 

 

 

0 Likes
1,049 Views
11 Replies
Replies (11)
Message 2 of 12

jeremytammik
Autodesk
Autodesk

Dear Gary,

 

Thank you for your report.

 

Can you please add a minimal reproducible case that I can pass on to the development team for analysis?

 

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

 

Thank you!

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 12

Anonymous
Not applicable

Hi,

 

I have attached a simple project that shows the problem ( element.CanBeHidden(view) returning false and 
view.HideElements(elementSet) failing). The app returns false for Revit 2019 and true for Revit 2018.

 

The path, private const string AddInPath = "C:\\ProgramData\\Tekla\\Revit-2019-Interoperability\\ImportToRevit"; and the ImportToRevit.addin file (supplied) needs to be modified to point to the correct ImportToRevit.dll location etc.

 

Any problems running the app etc then please get back.

 

Many thanks,

 

regards,

 

Gary Easom

 

0 Likes
Message 4 of 12

jeremytammik
Autodesk
Autodesk

Dear Gary,

 

Thank you for your clear description and reproducible case.

 

Ooops, though...

 

I just took a look, and it is rather a lot of stuff.

 

Do you really need Ionic.Zip.dll?

 

What is the meaning of '2014 Extrusion Issue.txt'?

 

Could you please remove everything unneeded, so that it is really minimal?

 

All extraneous content causes infinite confusion.

 

I would also suggest setting all the .NET assembly DLL 'Copy Local' compilation flags to false.

 

Currently, you are including all these DLLs, most if not all of which are probably not needed:

 

 

$ find . | grep -i dll
./bin/Debug/ImportToRevit.dll
./bin/Debug/RevitAPI.DLL
./bin/Debug/RevitAPIUI.DLL
./bin/Release/ImportToRevit.dll
./bin/Release/RevitAddInUtility.dll
./bin/Release/RevitAPI.DLL
./bin/Release/RevitAPIUI.DLL
./Ionic.Zip.dll
./obj/Debug/ImportToRevit.dll
./obj/Release/ImportToRevit.dll

 

The Revit API assemblies should always have their copy local flags set to false:

 

 http://thebuildingcoder.typepad.com/blog/2011/08/set-copy-local-to-false.html

 

Did you possibly zip up the wrong directory?

 

Thank you!

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 12

Anonymous
Not applicable

Hi,

 

 

Project (with several files and directories cleaned out, copy local flags looked okay?) reattached. Its really just a case of someone casting an eye over TeklaIFCImportForm.cs which shows the creation and attempted hiding of an element, any other unnecessary code and files can be ignored. 

 

Time is limited so I haven't been able to go over this test project in minute detail, but I think it clearly shows the issue. As mentioned this test runs fine in 2018 but fails to hide elements in 2019.

 

 

Thanks,

 

Gary

 

 

 

 

0 Likes
Message 6 of 12

Anonymous
Not applicable

Hi,

 

any luck reproducing the issue reported?  Is it possible to feedback any updated information?

 

Many thanks, regards,

 

Gary

 

0 Likes
Message 7 of 12

jeremytammik
Autodesk
Autodesk

Dear Gary,

 

Thank you for your update and sample material clean-up.

 

I compiled and installed your sample add-in in Revit 2019:

 test_panel.png

 

 

 

 

I launched the command and see the following form:

 test_form.png

 

 

 

 

I clicked the 'Create' button a couple of times, and then the 'Close' button.

 

What am I supposed to see?

 

OK, I went and debugged the thing, and I see that `beamSymbol` remains null in `ImportTeklaIfcFile`, so nothing happens; it just returns in line 147.

 

Can you please provide a complete and minimal reproducible case?

 

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

 

That may have to include a sample RVT file, or pick out some existing symbol from the standard Revit content libraries, or something.

 

It definitely needs to include detailed step-by-step instructions how to reproduce the issue.

 

Easiest would be to just provide the RVT with the required minimal model and a macro to drive it.

 

You cannot imagine how many issues have already been resolved by the developers themselves in their preparation of the reproducible case.

 

Since I cannot find any other reports regarding `CanBeHidden` or `HideElements`, I am starting to suspect that will help in your case as well.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 12

Anonymous
Not applicable

Hi,

 

thanks for getting back. 

 

I have amended the code so that it just picks the first structural framing symbol available in the project.

 

When the addin is ran a beam will appear in the project, that should be hidden. I have added a couple of messageboxs to report any issues.

 

That is it really, just repeat what you did before, it might be worth debugging in again and tracking whats happening. I can run this addin against Revit 2018 and the beam will be hidden, no problem, but the same code and hide element API call fails at 2019. 

 

Many thanks,

 

Gary

0 Likes
Message 9 of 12

Anonymous
Not applicable

Hi,

 

I have attached a zipped RVT project and macro that shows the issue.

 

  1. Run up the project, enable macros
  2. Create a 3D view
  3. Select manage/manage macros and then the application tab. Expand the HideTest module and then select the HideElem1 macro and run.

 

You should see a beam being placed in the 3D view which indicates an issue with the HideElement api call (works fine in the UI). Its worth stepping through the macro to see beam.CanBeHidden(view) returning false etc.

 

I hope I have included all the relevant files, HideTest.zip has all the macro code and HideElementsMacro.zip is the rvt  file

 

Many thanks,

 

Gary

 

 

 

 

 

0 Likes
Message 10 of 12

jeremytammik
Autodesk
Autodesk

Dear Gary,

 

Thank you for your update and new reproducible case.

 

Perfect!

 

I logged the issue REVIT-132226 [CanBeHidden and HideElements error in Revit 2019 -- 14179642] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 11 of 12

jeremytammik
Autodesk
Autodesk

Dear Gary,

 

Thank you for your patience.

 

The development team analysed issue REVIT-132226 [CanBeHidden and HideElements error in Revit 2019 -- 14179642] that I raised for you for this and say:

 

I've tested on 2019 and I'm not sure what is the problem:

 

In the statement `var canbeHidden = beam.CanBeHidden(view)`, canBeHidden is indeed false for the ProjectBrowser view type; for the other views, it returns true. However, if you call `view.HideElements(elementSet)` for an element which cannot be hidden in a view, then it throws an exception. This is what happening in the sample macro code attached to this issue.

 

I got another exception calling `cat.set_Visible(view, false)`, saying that the category cannot be hidden.

 

If I simplify the code a little bit, it works well in Revit 2019 and the beam is hidden:

 

  var canbeHidden = beam.CanBeHidden(view);
  if(canbeHidden)
  {
    view.HideElements(elementSet);
    
    //foreach (var cat in catList.Where(cat => cat != null).Where(cat => cat.get_AllowsVisibilityControl(viewInClosure)))
    //{
    //cat.set_Visible(view, false);
    //}
  }

   

The commented code throws an exception when calling set_visible.

 

So, I'm not sure exactly what your problem is, since both HideElements and CanBeHidden seem to work in Revit 2019.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 12 of 12

jeremytammik
Autodesk
Autodesk

The development issue REVIT-132226 [CanBeHidden and HideElements error in Revit 2019 -- 14179642] has now been closed as Cannot Reproduce. Please provide a working reproducible case for the development team if you still encounter any problem with this.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes