CADtools – the early years

My first Find and Replace tool

My first Find and Replace tool

Generates a sequence of attributes
I wrote this Attribute Generator to generate series of attributes, rather than copy … click … edit … copy …click … zzzz. As you can see I’m no UI expert. It ain’t pretty but it has saved me a lot of time over the years. The settings at the top-left are for generating ACNE-compatible attributes. It also generates in the correct order so you can bulk-select them and they will be in the correct order when you make a block of them. As you can see, I lost interest when it cam to making them different colours.
some tools I have butchered in LISP
LISP isn’t my favourite language but I’ve written (and butchered) a few routines that speed up my day. Quite a few of them are modified versions of the inbuilt ones (BX-BI is ATTOUT-ATTIN with a lot less clicks). I have far more sophisticated versions in the works.

As it stands I have a ton of ideas logged in my FogBugz tracker and some of them are partially coded. I posted my survey to assess the viability of developing these with a lot more finesse to sell them, or should I just hack them together for myself?

Please, let me know by taking my survey.

Advertisements

CAD tools survey 2011

For an explanation of the sort of tools I am referring to in this survey, please see http://www.cadbloke.com/cadtools-the-early-years/.

Thank you for your time spent completing the Survey. Please don’t forget to click “Submit”.
My contact links once more with proper links … If you have any suggestions or questions for me (CADbloke) then please feel free to

A summary of the results of this survey is published at http://www.cadbloke.com/cad-tools-survey-2011-results/. It will update automagically as more responses are received.

If you have a suggestion for a CAD tool you want to see please add it, and vote for them at http://cadbloke.uservoice.com/forums/130553-cad-tools-i-want-to-see

AutoCAD Layers are not Layers

Layers must be one of the most misnamed things in AutoCAD.

The one thing that AutoCAD “Layers” don’t do is actually layer objects. This is controlled by the Draw Order commands. That’s what I mean when I say “Layers” are not layers. They are nothing at all like the olden-days concept of drafting on transparent paper and layering them on top of each other.

AutoCAD Layer Manager

AutoCAD “Layers” should be called Collections, or Bundles. They are a way of grouping objects (lines, blocks, text, whatever you like) together so you may easily adjust properties they share. The most obvious and prolific use is color. When you set the color property all of the objects on a “Layer” to “ByLayer” then you change the color of everything in that “Layer” simply by changing the color of the “Layer”. This is ultra-handy because it centralizes object properties you want to tweak, en masse. If you want to change the color of video cables in a drawing from blue to pink, you only need to change it in one place – on the Video “Layer” in the “Layer” manager.

“Layers” also work inside blocks. Anything inside a block that is not on “Layer” 0 (zero) is a member of the “Layer” it is assigned to and will change along with everything else on that “Layer”. Layer 0 (zero) inside a block is a whole other topic.

Full-screen Shortcut for AutoCAD

I wanted a full-screen shortcut like Internet Exploder, Firefox and other web browsers, just for having a good look at a drawing on the whole screen with no distractions.

The Cleanscreen command is a good start but it didn’t go far enough for me, so I hacked it and added a few things to it. Now my full-screen has only the Top window bar with the quick-access menu and nothing else. Just this …

AutoCAD - Quick Acces toolbar only

… the thin edge of the window itself and wall-to wall CAD.

  • F11 –> Absolutely everything disappears. Full-on full screen
  • F11 again –> all the toolbars, status bar, menus come back to their rightful place

How?

AutoCAD-CUI-Macro windowOpen the CUI Editor and follow the instructions in AutoCAD’s help system – F1 –> search for “To create or modify a shortcut key”. Their well-illustrated explanation saves me cobbling one together. The only thing I’ll add to their instructions is that you can narrow your search of commands by typing any (that’s cool) part of the command’s name in the search box in the Command List section of the CUI window (bottom-left).

I dragged the “Clean Window” command onto the Shortcut Keys node. This is the command I started with before I broke perfected it. Click on the Macro line of the command section on the right in the CUI window (highlighted in red), then click on the […] box that appears on the right (trust me, it appears).

… then paste this code in the Long String Editor (actually, read to the end of this post because there is a better version below. I left this here for history’s sake)

$M=$(if,$(and,$(getvar,CleanScreenState),1),^C^C_CleanScreenOFF _commandline _MenuBar 1 statusbar 1,^C^C_CleanScreenON _commandlinehide _MenuBar 0 statusbar 0)

It is important to note that the spaces in the command list are significant so make sure you select all of it at once. The spaces (and commas, as it turns out) are the same as pressing the enter-key to execute the command. The observant amongst you will notice there are a few more characters in the screenshot. My original code needed a bit of a tidy-up.

If you haven’t already, assign a key to the shortcut, as per Help’s instructions. I used F11. Why? It is the same shortcut for most Internet browsers to go full-screen. For once, I’d like AutoCAD’s User eXperience to match something from the real world. Don’t get me started on that. Find. Replace. 3 Tab stops. Why?

That’s the practical part, done.

How it Works

For those of you who love to know how it works, here it is in its 3 parts. It is a Diesel (see AutoCAD –> F1) Macro. Notice that there are 3x commas in the if command which wraps the macro. The format of this macro is basically [Test], [Do if True], [Do if False]. Here is the same macro on 3 lines

$M=$(if,$(and,$(getvar,CleanScreenState),1),

^C^C_CleanScreenOFF _commandline _MenuBar 1 statusbar 1,

^C^C_CleanScreenON _commandlinehide _MenuBar 0 statusbar 0)

Working through the macro, this is what it does

  • the first part checks to see whether you’re in Cleanscreen mode or not.
  • the rest of the macro is in two halves, Cleanscreen on, Cleanscreen off
  • wherever you see ^C^C_ that means Ctrl-C, twice. This exits any lingering previous commands. My original code had a few superfluous Ctrl-C’s.
  • CleanScreenOFF returns the menus etc. that the CleanScreenON command in the 2nd half of the macro hides
  • commandline restores the command line which is hidden by commandlinehide
  • MenuBar 1 and MenuBar 0 restore / hides the file-menu bar at the top for old farts like me who have grown attached to it.
  • statusbar 1 and statusbar 0 show and hide the status bar which is right at the bottom of the AutoCAD window.
  • as yet I haven’t figured out how to show and hide the Model / Paper Space tabs.

Remove any of the above combinations if they don’t suit you. Don’t forget the ^C^C_ at the start and the trailing space. Feel free to add anything to the macro and also please add it here to the comments.

**Update** I figured out how to show & hide the Model / Paper Space tabs.

AutoCAD Model & Layout Tabs

Add the code below to the bottom of your acadXXXXdoc.lsp (XXXX is the version of AutoCAD you are using). I found it in C: – Program Files – Autodesk – AutoCAD 2011 – Support**Update**  My bad – you are not meant to modify these files. Find (or if it doesn’t exist, create) a file called acaddoc.lsp. See the link in the previous sentence for where to create this, depending on how specific you want it to be. By default AutoCAD will walk the support paths list looking for it. Basically, just put it somewhere in your support path, perhaps in the same place as the one you’re not meant to modify.

The following LISP code sets up the commands to show and hide the Model / Paper Space tabs. You can actually use the commands anytime you want. Use Notepad or a similar plain text editor. DO NOT USE WORD !! Make a backup first, just in case. Watch out you don’t miss any brackets – they are annoyingly important)

(DEFUN C:MLTABSON ()
(setenv "ShowTabs" "1") () (PRINC)
)
(DEFUN C:MLTABSOff ()
(setenv "ShowTabs" "0") () (PRINC)
)

Before these lines at the end of the acaddoc.lsp file (or add them if they don’t exist):

;(princ "loaded.")
;; Silent load.
(princ)

The new macro to paste in the Long String Editor is:

$M=$(if,$(and,$(getvar,CleanScreenState),1),^C^C_CleanScreenOFF _commandline _MenuBar 1 statusbar 1 MLTABSON,^C^C_CleanScreenON _commandlinehide _MenuBar 0 statusbar 0 MLTABSOFF)

Here’s a tip conveniently placed at the end to see who dived in and who read the whole post before tinkering … Open a text editor and copy-paste your macro code at various crucial stages. This will give you an easy way to go back if you miss a space, comma or just generally mess it up.

One Version of the Truth

One truth amongst many representations of the same truth

One truth amongst many representations of the same truthThere should only ever be One Version of the Truth in any documentation system,in anything that involves the management of data, especially where the data is timely and subject to change. This I decree to be CADmandment Number One. To continue the Biblical reference, shunning this is the the root of all documentation evil. Most problems you will have with a data or documentation system can eventually be traced back to this root cause. ok, that’s enough of the Biblical references.

Ignoring this CADmandment will slowly and inevitably break your Documentation System.

As a system gets more complex (have you ever known one to get simpler?) a disconcerting number of the changes you make will inevitably have loose-ends,  inconsistencies, duplicates, orphans and WTF-was-I-thinking moments. The gap between what is documented and what is actually there will inevitably widen, as will the cracks in your documentation system. Documentation Systems crack and break at the joins. As an aside, remember – anything new also counts as a change.

I use the word inevitable here a lot. Initially it was an unconscious decision. I think it was a good one so I’m sticking with it. It is the natural order for things to flow along the path of least resistance. This is true for water and electricity and it is true for people also. One Version of the Truth is all about laying the foundation to make success inevitable, not failure. If you make it harder to succeed than fail then fail, you inevitably will. The system should be your servant – not the other way around. It is of your making. More on that another day. Oh, if you don’t have a documentation system – make one. Now.

What is One Version of The Truth ?

Do not store any information more than once.

Ever.

What – you want more? ok but this is gunna be a long one. I promise that my future rants will be (mostly) more concise but this is The Big One. There is a fair bit of industry-specific jargon here which I will soon (I hope) write a glossary for. If the magic has happened (ie. I wrote them) then the jargonese should link to a explanation of said jargon. One day. I promise. Rightyo, this is what it all boils down to…

There should only be one root-source,

one fountain of knowledge.

You may certainly derive a report from The Truth at any time but never treat this report as you would the original Truth. That report is an out-of-date and disconnected snapshot of The Truth from the moment it is generated. Spreadsheets, Cable Schedules etc are (usually) reports generated from the source of the truth – the schematic drawings. The reports should be clearly identified as such. They should be consciously labelled with the exact time they were generated so nobody ever forgets that this report was, at best, a snapshot of the truth. If you are looking for the truth for now then you must either regenerate this report or look elsewhere (in the racks, for instance, where the Real Truth lies). If the message that “This Is A Report From This Time” is explicit then it removes an inevitable gaping opportunity for misunderstanding.

Have you have ever wondered why a lot of wiremen prefer to work from schematics rather than cable schedules? It is because they implicitly know how the process (usually) works – the schematic gets updated then, later, the cable schedule (sometimes, eventually…) gets updated. They also know that if the cable schedule is generated manually (by a human scanning drawings) then it will inevitably contain tragic and expensive mistakes. It just does. They know this because they have seen it countless times.

This is of, course, not true if the cable schedule is indeed the oracle, the owner of the information. Then any drawings you have are simply reports of the cable schedule. That said, those drawings should be overviews only, deferring the details to the cable schedule which is the rightful owner of the nitty-gritty information.

Again – all reports should be clearly labelled as such so they are not assumed to be the original source. Sooner or later some poor Innocent will update them and then disaster will ensue. Suddenly the drawings and the cable schedules say different things and nobody knows which one is right or wrong. Odds are they are both wrong in the own peculiar ways.

Many things we do every day break the First CADmandment. Offsheet drawing references (manually adding a pointer from one drawing to the next) break this rule really, really badly. They never get updated. Manually cross-referenced room and rack layouts versus their respective schematics (also often versus the cable schedule) is probably the second-most prominent example of this. Stop and have a think about it – I bet you can name a scary number of everyday things you / we  I do that violate this rule. When you think of them, please add them to the comments below.

By making one place only the source of the truth you can easily find the real truth, and the source for the real truth – there should only be one place where you know you need to look to find the truth. Then, and only then, can you change the truth and be sure it will be, indisputably, the new truth.

Should we stop breaking the First CADmandment right now ?

My short answer is … YES! … eventually but you won’t be able to stop suddenly. Rome didn’t burn in a day. You / We / I will need to evolve our behaviour and practices – indeed our Documentation Systems – towards a model that reduces, if not eliminates, violations of CADmandment Number One, The One Version of The Truth. Strive for it. It is a difficult goal but it is, as far as a Documentation System goes, the most important goal. It is also probably one of the hardest goals. Oh, yay!

This is CADmandment Number One for a bloody good reason. Ignore it at your peril. If you choose to dismiss this CADmandment then you may as well dismiss the rest of my rants on this site. Seriously. This is the one problem that will cost you more time, heartache, swearing, tantrums (oh, that’s just me?) via inconsistencies, conflicts and mistakes, than anything else I have discovered so far. These stuff-ups always happen at the worst possible time. Oh, yes, You Know It.

Oh, and while I’m at it – forget about updating any information in reports – you’re shuffling deckchairs on the Titanic – today. That report is literally history. Generate a new report from the real information – the Truth.

Yes, I know this Article sounds pretty bullish and know-it-all. Take it from me – I don’t know it all. I will endeavour to not make it a habit but I make no apologies for this here and now. This CADmandment Number one is really important.  As an aside, a special thank-you to Catherine Eibner for introducing me to this concept. She knows stuff – lots of stuff.

So, do you agree, disagree or did I just confuse you? Please let me know your thoughts via a comment below.

More Reading:

http://en.wikipedia.org/wiki/Don%27t_Repeat_Yourself

http://en.wikipedia.org/wiki/Single_Source_of_Truth

http://www.computerworld.com/s/article/88349/Business_Intelligence_One_Version_of_the_Truth?taxonomyId=009

tvCAD – a Replacement for ACNE

After much (years!) ado, here it comes…

Before the end of 2015 I will be shipping tvCAD.

Interested? Please drop into http://www.tvcad.tv/ and I will keep you in the loop on its progress. There’s an email list there which will give you direct access to me and to the development process. Please, drop in, have your say and let’s make this happen.

Gaping Void made this awesome Information - Knowledge image
Turn your information into Knowledge

ACNE doesn’t like A$ Blocks

Greetings. Long time no see read. I’ve been a little busy in the last couple of years, working on the things. Like most good intentions, the nearly-100 unpublished blog posts hidden in the caves of this site are still there, I will endeavour to see if any of them are still relevant. Well, I hope I will endeavour.

Today’s ACNE rant / warning – it seems to ignore blocks whose name starts with A$ inside AutoCAD, they are created by pasting a block into a drawing. If you rename the block (I just remove the A$ prefix) it should work – I haven’t tested that part yet.

ACNE is also not a fan of blocks that haven’t been ATTSYNCed.

ACNE Doesn’t Like Apostrophes

ApostropheIf you’re using ACNE then don’t use any apostrophes in your block attributes. They (apparently) mess up an internal query when it is parsing drawings which I am presuming results in lost data.

If you’re wondering whether you have this problem or not, look at C:ACNELog.txt and search for the word “syntax”. If you want to be even more thorough, search for the word “error”. If you find one that puzzles you, post a comment here and we’ll see if we can solve the mystery together.

On another note, my humble apologies for my lack of posts here. I have had a busy year so far. There are plenty of half-written posts just waiting or me to refine them into something sensible so they can see the light of day. I hope to get more posts up after the next month or so.

CAD tools survey 2011 Results

I posted a survey at http://www.cadbloke.com/cad-tools-survey-2011/  to assess the feasibility of releasing a few of my custom CAD tools into the wild. If you haven’t already done so, could you please help me out by completing the survey? For an explanation of the sort of tools I am referring to, please see http://www.cadbloke.com/cadtools-the-early-years/.

If you have any suggestions for CAD tools you would like to see then please add them at http://cadbloke.uservoice.com/forums/130553-cad-tools-i-want-to-see

It may strike you as a little odd that I would be so open about releasing this info but that’s the way I like to do things. I’m not a fan of keeping secrets just for the sake of it. Also, I believe that your time spent on helping me out should have some payback, and here it is…

This page will automatically update when more results come in so, if you’re interested, come back & see how it’s going.

Here are the results

Thank you once again for helping me out with this survey. If you haven’t already filled it out, please add your thoughts at http://www.cadbloke.com/cad-tools-survey-2011/ .

If you have any suggestions or questions for me (CADbloke) then please feel free to leave a comment below or, alternatively, get in touch with me at http://www.cadbloke.com/contact/ or via Twitter at @CADbloke or on Linked-In at http://www.linkedin.com/in/cadbloke

If you have a suggestion for a CAD tool you want to see please add it, or vote for it, at http://cadbloke.uservoice.com/forums/130553-cad-tools-i-want-to-see

AutoCAD LT Missing Plot Styles

AutoCAD plot style missing

I dunno, perhaps AutoDesk are punishing you for buying the cheap version. Perhaps I am a bit too cynical about these things. That’s quite likely.

You’ve just installed AutoCAD LT, opened your first drawing in it and gone to print it.

AutoCAD plot style missing
screenshot from the full version - your mileage may differ

“Missing or incompatible plot style” WTH? I thought that was one of the ones you get when you buy AutoCAD (LT). Does it cost extra? Gaaahhh!

Here’s the issue – the “grown-ups” (full) version of AutoCAD, the one that makes Autodesk an obscene amount of money instead of just a lot, has a collection of plot styles whose names differ from the LT version that you have now just been punished for buying. For exampleinstance, the run-of-the-mill “Color-dependent Plot Style Table” in AutoCAD is called “acad.ctb” but the equivalent plot style in AutoCAD LT is called “acadlt.ctb”. Why? DO NOT ASK WHY !! There’s nothing to be gained from that.

Plot settings, including the assigned plot-style, are saved in the drawing. Thus begins an ongoing plot-style tug-of-war between the Full version crowd and the LT crowd. You just backed your Ford into their BMW. The irony here is that the real fault lies with whoever designed the carpark (to continue the analogy).

Solution: copy, and then rename the copies of all LT plot styles with “lt” at the end of their names.

How: The “stylesmanager” command which, rather unintuitively, opens the folder containing the plot styles. You’re on your own from there. Double-click them if you actually want to edit them. It’s also in the file menu (“menubar 1” to get your old friend back) and it’s probably buried in the ribbon somewhere too, right next to the “create new layer” button, no doubt. Don’t ask me where, that thing hurts my eyes. If you click on the AutoCAD logo at top-left it’s here …

Plot styles from the big A button at top-left
I much-prefer the Quick access toolbar to the ribbon.

You could say it looks like a bit of a shell game to separate the two versions but, IMHO,  it’s more likely due to Hanlon’s Razor. Either way, it’s a broken User Experience. You’re now pissed off for no good reason. Maybe the Full version and LT teams should do lunch or something, compare notes. We’re all on the same team, you know?

AutoCAD Find and Replace Wildcards are broken

so far, so good

Update in 2015 – it’s not a bug as such but a usability issue – as an aside the dot (period) wildcard matches any single non-alphanumeric character, similar to a question mark but much more restrictive. Curiously I would expect it to match a dot, which is does here. The cause of the confusion is still the lazy versus greedy aspect.

This frustrated me so much over the years that I wrote a replacement for Find and Replace where you can be selective about what wildcards to use. Oh, and it lives in a tool palette so you don’t have to keep opening and closing a window. Check it out.

…returning you to the original post…

I found this bug when doing a find and replace on some IP addresses in an AutoCAD drawing. I was using it as a template for a new drawing so I wanted to reset the IP addresses to a default to avoid duplicating the existing values.  Here is what I started with …

so far, so good

So, I fired up my trusty AutoCAD Find and Replace window, like thus…

AutoCAD Find and Replace window. Finding *.*.*.* and replacing with xxx.xxx.xxx.xxx

… and then selected the block in question & hit Replace All. I got this …

Not the desired result. Huh?

That ain’t right. I tried the same thing in Excel. From this …

Same procedure in Excel, before

… using the same Find and Replacement text …

Excel Find and Replace Window

… and I got this …

Replacement in Excel - ah, that's better

That’s more like it. To paraphrase Sesame Steet, “One of these things does not work like the other ones.”

So, why are they different?

Initially, I thought the difference was that Excel’s search is greedy and AutoCAD’s search is an inconsistent mix of lazy and greedy. Here is an explanation of the difference between lazy and greedy text searching, as it pertains to using Regular Expressions. In a nutshell, a lazy search reckons it is done when it has found the bare minimum it needs to satisfy the requirements of the search. The * wildcard I used in the find section will match one or more of any character. A lazy search reckons it’s done when it matches one character, a greedy search will keep matching characters until it eventually runs our of ones that match the search string. In Excel’s  case it stops when it gets to a dot, in AutoCAD it did that with the middle but not at the beginning and the end.

The more I looked at it the more I realised that isn’t right. AutoCAD had actually ignored the first and last wildcards in the search. Instead of looking for *.*.*.* it has looked for .*.*. As Occam’s Razor inevitably predicts, it’s not as complex as I first thought – it’s simply somewhat broken.

I’d say that’s a bug, folks. I guess I’ll be using ol’ faithful Excel for that find and replace exercise. Well, actually, it’s not that bad – the ? wildcard still works so I can use ???.???.???.??? in various number of ?’s to (eventually) get there. It’s still a bug, though.

ACNE and the case of the Missing Cable Numbers

from http://www.flickr.com/photos/wilhei/109403306/

from http://www.flickr.com/photos/wilhei/109403306/OK, I’m staring at the drawing and I know all the blocks and attributes are right. I have run the drawing through ACNE more than once and I get the same result: some of the cables are missing from the cable schedule. Why?

This is an easy mystery to solve but a PITA to eradicate. The problem is that the block has been changed in some way but has not had the ATTSYNC command run on it. The attributes in the (original) block definition don’t match the ones in the insertions, the copies of the Definition that you can see.

So, to fix it, go through the motions of the ATTSYNC command. If you’re using AutoCAD LT then this command was introduced in the 2010 version. Older versions don’t offer it. If this is your dilemma, try Ctrl-C copying the whole drawing and pasting into a blank template, then use the new drawing you just created. Be aware you will lose any uninserted blocks if you abandon the old drawing. I can’t guarantee that will work because I don’t have a copy of LT to try it out on.

So, why is the ATTSYNC problem a PITA to eradicate? Well, how many blocks in your drawing set need ATTSYNCing? How can you be sure you’ve fixed them all? Also, be aware that ATTSYNCing moves all of the attributes in every occurrence of the block back to their originally-defined positions. If you have spent hours dragging attributes left, right and everywhere to make them line up then this will break that. That’s the main reason I don’t advocate moving attributes away from their defined positions – you paint yourself into a corner. Don’t do it.

Installing ACNE on Windows 7

There are two parts to the Windows 7 and ACNE tale – installation and running. The crux of the matter is that you need to install and run ACNE as a Windows XP compatible application, primarily because ACNE was originally developed to run in Windows XP. Although Windows 7 is pretty good at eventually figuring this stuff out for itself, you’re always better off doing it properly and telling the operating system what is going on.

Installation

Right-click the installer file, click properties and then go to the compatibility tab.Set it to be compatible with Windows XP. I don’t think it really matters if you choose Service Pack 2 or 3 from the list. I chose Service Pack 2 because it was the current one when this version of the program was compiled. As this is an installer it will need to run with Administrator rights. It will trigger a UAC response when it installs – this is ok. Actually it’s great. UAC is great. Never turn it off. No, seriously.

ACNE-install-compatibility

 

Running

In Windows 7 To set ACNE to run in XP mode. Right-click the actual acne.exe file,click properties, compatibility & set to XP sp 2 or 3 mode. It doesn’t need to run as Administrator, which is good practice anyway. You should only run a program as Administrator if you desperately need to (ie. the installer, as above). It can make the difference between a program crashing-and-burning itself, or your whole computer.

ACNE-exe-run-compatibility

While you’re at it you should probably tweak the shortcut you use in the start menu as well. The procedure is the same … right-click the shortcut and click properties …

ACNE-run-compatibility

That should do it. If you have any questions, comments or tips, please feel free to add them here.