I have been very busy and motivated indeed setting up a new computer this week.
Nonetheless, I was able to keep going full steam with Revit API related issues as well:
- Setting up a new MacBook
- KLH Engineers RevitDeveloperTools snooping tool
- Pulling text from annotation tags
- Vertex handling
- The true meaning of pizza
Setting up a New MacBook
I picked up my new computer on Monday, a MacBook Pro.
Migration worked very well so far, installation was easier than ever before, and I am already almost completely done moving over.
These components are now up and running:
- Google Chrome
- Pulse Secure
- Microsoft Office
- Outlook credentials
- Komodo Edit
- iterm2
- Parallels
- Windows 10
- Visual Studio 2017
- Revit 2020
- VeraCrypt and osxfuse
- Skype
- VLC
- Firefox and downloadhelper
- git
- Personal Komodo editor scripts
- Created and set up new GitHub SSH key
- Migrated personal disk data to new machine
- Restored bash profile
- Python 3.7.4
- pip –
pip3 install --upgrade pip
- Python markdown:
pip3 install Markdown
- git-lfs – installation
- Internet browser bookmarks
A few security related issues remain to do:
- Desktop Duo for VPN access
- Replacing my obsolete TrueCrypt encryption system
I am writing this blog on the new system, with significant help and inspiration provided by my baby lizard friend presented in the image above.
By chance, now that I almost finished, I also just read this helpful article on how to set up your new MacBook for coding by Amber Wilkie on freeCodeCamp.org. I have already completed many of the steps she suggests; still, a few are new and useful for me as well.
KLH Engineers RevitDeveloperTools Snooping Tool
More Revit API related, John D'Alessandro, Software Engineer at KLH Engineers, PSC shared a powerful new Revit database snooping utility, explaining:
We at KLH Engineers decided to roll our own Revit Snoop tool a while ago and we thought we’d show it to you so you can check it out.
We released it as a class library on our GitHub so that others can use it in their own tools and solutions.
We’re also accepting issues and PRs, so the more people use the tool the better it’ll get. Let me know if you have any feedback on it or questions.
The repo is at KLH Engineers RevitDeveloperTools.
It has some similarities and overlap with RevitLookup, and adds a number of features not available there.
The README includes a feature list comparing the two snooping tools:
Many thanks to John and KLH for implementing and generously sharing this powerful new snooping tool!
Pulling Text from Annotation Tags
One quick note on a small issue that was not discussed in the public Revit API discussion forum seems worthwhile sharing here:
Question: I'm trying to pull the text from the annotation tags on a drawing using the Revit API. Is that possible? How?
Answer: Yes, this is definitely possible.
You can use a filtered element collector to collect all the annotation tags, and then access their text via their properties.
To retrieve the tags, you need to determine what class they have. I assume they are IndependentTag class instances.
The property to access their text is presumably the TagText property.
You can install and use RevitLookup yourself to validate these assumptions of mine in your own specific model.
If these assumptions are correct, the final solution might look something like this in C#:
#region Pull Text from Annotation Tags /// <summary> /// Return the text from all annotation tags /// in a list of strings /// </summary> List<string> PullTextFromAnnotationTags( Document doc ) { FilteredElementCollector tags = new FilteredElementCollector( doc ) .OfClass( typeof( IndependentTag ) ); return new List<string>( tags .Cast<IndependentTag>() .Select<IndependentTag, string>( t => t.TagText ) ); } #endregion // Pull Text from Annotation Tags
For future reference, I also added this code to The Building Coder samples in the CmdCollectorPerformance.cs module
Finally, you can use the built-in Revit macro IDE (integrated development environment) to convert this code from C# to Python, if you like.
Vertex Handling
Another recent recurring question on vertex handling may also be of general interest:
Question: When processing meshes or other collections of triangles, is there any way to know if one vertex is shared by multiple triangles?
Thus, the final data does not have to contain duplicate vertices and can reuse the existing vertex indices in order to save data size.
Answer: I have often used strategies similar to the following when collecting mesh data:
- Implement a comparison operator for the mesh vertex coordinate data.
- Store all mesh vertices in a dedicated dictionary using the mesh vertex coordinates as keys, e.g.,
Dictionary<XYZ,int>
. Theint
is not really important, just the keys. I often use theìnt
value to count the number of vertices encountered at each location. - For each new mesh vertex received, check whether it is already listed in the dictionary. If so, increment its count; else, add a new entry for it.
The comparison operator needs to accommodate an appropriate amount of fuzz, cf. this dimensioning application.
For some examples, look at GetCanonicVertices
for tracking element modification and
this post on the XYZ
class.
For yet more examples and use cases, you can search The Building Coder for
XyzComparable
XyzEqualityComparer
XyzProximityComparer
The True Meaning of Pizza
I am writing this visiting my friend Dani in Verbania, Italy.
Hence, this little note in closing:
Did you ever wonder why pizza is called pizza?
Well, pretty obviously, it simply represents the formula used by a hungry mathematician to determine its volume from its radius z
and thickness a
:
Volume = π · z 2 · a = pi · z · z · a
Pizza volume formula V = pi·z·z·a