The notoriously detailed AutoCAD .net documentation strikes again! What exactly is meant by a collinear LineSegment2d? Who knows? Luckily the documentation is there to save the day:
Here is the relevant GitHub issue. They were so sneaky. The posted a ruby gem, but with some sneaky additions. This was not posted on Github. They were hoping that nobody would notice. But someone did. In order to pull this off, you’d have to be a fairly sophisticated rubyist, with a good understanding of rack, and some basic security knowledge exploits. They must have some time on their hands to pursue such nefarious ends.
Dynamically Dispatching Methods
Prawn is my go-to pdf generator, when using a Ruby on Rails application. I wanted to create a table in prawn, and having no idea how to do so, stumbled upon an article on-line on how to do this. Without it, I would have been lost.
Nothing could be more paramount, in the writing of code, than to make it understandable and legible. You will be greatly assisted in the latter task, if you employ a beautifier, that styles everything automatically for you. If you are using Sublime Text 3 as your text editor, then you can employ the “BeautifyRuby” package to help automatically indent and style your rails templates.
Explanation of the concept without code:
I’ve written a command which helps takes panels from the marking plan to creating an elevation view. This command will hopefully reduce errors and improve efficiency. I call it the CopyMarkingPlanPanelsToLayout.
Consider the following code:
Demo of a little command I wrote:
- I own all the data in the app.
- I bear no liability for anything.
This gave me a little bit of grief.
A cheat sheet for myself to refer to it, when required. It may benefit you as well. HTH.
Ok this nearly killed me:
The Goal In Any Endeavour:
My personal cliff notes in getting this up and running ASAP (without worrying about AJAX or server-side processing). That come come later. I suppose it’s a problem that you want to have.
I wanted to create a mock file system, rather than a real set up. It’s a lot easier. Plus you can easily stub for certain specific situations you want to test for.
A code snippet to show you how to get at some common path / directories. I tend to use the methods of combining, because occassionally, AutoCAD’s current drawing path is not it’s current drawing path (when for example you use the Database.Filename property of the .net API) - but instead, what is returned is a path deep in the bowels of Window’s temp directory comes up. And that’s obviously the wrong value. So a hack I tend to use is to combine the drawing name (excluding the path) and the directory of where the drawing currently resides, and to combine the two using a
System.IO.Paths.Combine(...) method (you’ll have to pass in the appropriate parameters of course) to come to the desired answer.
Key points/notes on how I did it:
The jargon is sometimes confusing for me. So here is a cheat sheet to refer to if you forget:
A very handy method. Often detailers will ask for something to be placed on a particular layer. But since they are using a 100 different drawing templates without any consistency nor standards, the onus is on you to impose that standard on them. So you’d have to check for a layer and add it if it doesn’t already exist. Anyways, that’s enough griping: here is the code:
We want a selection filter which simply ignores certain types of colors.
This can be difficult and extremely frustrating if you get it wrong, because AcCoreConsole is not the most user friendly interface out there – but, it is extremely fast. If AutoDesk combines AcCoreConsole with some kind of super fast in memory cache like Redis then operations will be an order of magnitude faster; and even better than that would be if the.NET API is changed to incorporate the smart GraphQL query specifications that I am pretty sure will leave behand Restful APIs in its wake. I digress.
A simple code snippet for getting all the block names - which I lifted from Gilles:
Ok, so we’ve done some significant refactoring.
The insidious nature of bugs that you are blind to, means that you can never find it.
Extracting Bolt Distances of Single Part Drawings (Beams) With an Output In Excel – Part III (Tekla Open API)
Getting Bolt Distances From Single Part (Beam) Drawings With an Output In Excel – Part 1 (Tekla Open API)
Extracting Bolt Distances of Single Part Drawing (Beams) With an Output In Excel – Part 2 (Tekla Open API)
Usability – The Human Problem In Developing Unique and Wonderful Software (Usability and Learning Curve)
What’s the difference?
What is the difference between typical WPF/Winforms applications which do not incorporate the MVVM pattern and those that do?
Pass in through a constructor, and then call – or pass in directly through a method? – A Question of Design (OOP)
What’s this all about?
Ferrule Clash Checks in Precast Panels – Check the Elevation From the Marking Plan (AutoCAD .net API)
Where did the AutoCAD File Dialog User Interface Go – How to Return it back to normal after using AcCoreConsole? (AutoCAD)
A commenter had some trouble loading the files. So perhaps the AcCoreConsole is confusing people. So here is a post which will hopefully clarify how to do it.
This is another refactoring problem I answered on CodeReview.
What is this fishing app?
The AutoCAD .net/ObjectARX APIs have a handy feature called the pick first selection.
I can’t say it any better than what’s said here. It’s masterfully explained and brilliantly clear with .gifs to illustrate the concept. Would highly recommend you take a look, especially if you are writing complex multi-threaded applications.
You might not know this but I have a part time job, at the golf shop. One of my duties involves: stacking the shelves full of products.
Binding Basics: Unfortunately this note will not be for raw beginners with no understanding of WPF.
Explanation without code
There seems to be a lot of confusion with folks about the difference between using the AutoCAD .net API vs the COM Interop API. They both hope to do the same things, but via different ways. Given a choice, I’d always recommend using the .net API because it is much more powerful. Or if you are familiar with C++ then go for ObjectARX API which gives you immense power. You may think that using .net API obviates the need to manage resources - but you’d be wrong: the .net API is simply a wrapper to the underlying unmanaged types. You have to explicitly use transactions or you have to otherwise explicitly dispose of objects after you’ve finished using them. Nevertheless, the .net API is still very good to use in certain instances.
So you’ve inserted a block reference into the model space. Very good. And you’ve decided to rotate it and move it around. Again: very good. Now you wish to programmatically place more block references, similarly rotated, but perhaps spaced some distance apart. How are you going to do this.
Wouldn’t it be handy if we could programmatically insert reference models into Tekla? Well you can now do so quite easily.
It is rare that I see masterpieces on CodeReview, but this was one that warrants incredible kudos:
We have already outlined in a previous post, what a stub is, and the benefits of unit testing.
Please do the sample questions if you really want to learn this stuff
I see this problem all too often in stack overflow: a situation where folks check for the type of a class in an if statement, and then respond accordingly. Rather than repeating myself a million times, I thought it much easier just to write a post on the subject (DRY FTW!). Anyways, this type of code (pun intended) smacks of a duck type not being identified and utilised.
Imagine you have two classes. A parent and a child class. The child inheritance from the parent. Therefore the child should be able to do everything that a parent does and possibly more.
Last post we looked at dependencies and isolating them. This post we are going to work through some exercises.
In a post a few weeks back I was griping about the limitations of Tekla. Ideally I’d want to resort to enums to get access to a particular property. But Tekla forces you to use strings directly to query for the property you are after. This is a minor inconvenience. So I devoted three hours of my life in the service of the public to ensure that nobody suffers anymore.
So I have a JSON string that I want to parse into a JSON object:
Did you folks know that this was possible: you can have a master word document and have sub documents linked to it. I can’t say it any better than they say it here: so i’ll just post the link.
I’ve created another Tekla plug in – here it is. And I’m calling it using a macro.
How to reference your AutoCAD COM interop assemblies?
With software, the hardest part is getting to the bit where you can say “HELLLO WORLD BABEY”. Because once you are there, then the rest is downhill.
Ok, time for the first hello world post
Please follow the follow steps to ensure that your .net dll works:
It’s simple. Ensure that you are on the current branch. Then simply:
What happens if you accidentally delete a branch?
If you want the file path of a dawing simply use the following:
Let’s say you have an array of ObjectIDs. And you want to filter out and keep all the lines. How would you do that?
When you are testing something you’ll want the code to run in a particular way, but when you are dealing with the real thing – in “production” mode – then you might not want to have the test code there as well. How can you manage this in c#?
Normally you’d go straight for the .Contents property…and I did just that but I also got some formatting marks. So how’d you get it without them?
You want certain objects to be selected at the end of a command. How do you do this?
A curious feature to be aware about Ruby.
Now you want to access the modelspace ObjectId.
Question: What is the difference between using .fetch() on a hash rather than just hash_object[:key]? They both do the same thing, right?
Question: What is the most exciting thing since sliced bread?
What is the difference between rails g: (a) scaffold vs (b) model vs (c) resource?
How it’s done
A brilliant example which I basically restructured from some code Gilles provided:
What is the Editor.CurrentUserCoordinateSystem transformation matrix able to do?
Tunnelling – What is it?
It’s not very often that I write something on the Autocad .net API, so here’s something which you, I suppose, will need one day:
Most of the above answers use code. There is no point me repeating what they say, so I’ll try to explain the concept without code:
What is meant by implementing an interface?
What is an external dependency?
What is the difference between a unit and integration test? Consequences of using dependencies in your unit tests.
What is a class under test?
With Assert.Throws() you can be really specific. You can say: an exception will be thrown at this method.
Difference Between IEnumerable and IQueryable
I’ve had occasion where I’m cutting and pasting code and it comes out in a nightmarish form in Visual Studio:
“The beginning of wisdom is to call things by their proper name.”
- Ancient Chinese Proverb
What is a call-back function?
This used to confuse the life out of me.