Monday 6 November 2017

CorelCAD 2017 review

CorelCAD 2017 £759.99
https://www.coreldraw.com/en/product/corel-cad/

For 3D CAD, CorelCAD seems to provide a lot of power at a moderate price. But does it live up to its promise? Dermot Hogan gives his opinion…


One thing that you learn quite quickly about lathes, milling machines and the like is that, unlike a PC, there isn’t a delete key. If you make a mistake, you start again. Which is why it is pretty much essential to have a CAD package to produce a design – a plan – from which to work. Yes, you can use graph paper and a pencil to produce a design. You can also use a quill and ink if you like …

I’ve been using CorelDraw for a number of years as a (very) lightweight CAD package for simple mechanical drawings. It works quite well for that, in that you can add dimensions, use layers and colour items to get an idea of what you want to produce. But a 2D package that is aimed mainly at artists and illustrators doesn’t really cut it when you want to produce something like a simple right-angled mounting plate - let alone a robotic tracked vehicle. Nor, to be fair, is CorelDraw intended for that purpose.

So I started looking for something a bit more 3D-oriented which would fit in with what I had used and knew in CorelDraw.  CorelCAD seemed the obvious place to start.

CorelCAD is essentially a re-packaged version of Graebert’s Ares Commander CAD system. It’s aimed squarely at AutoCAD-style users and as far as I can see does a pretty good job of it too. I’m no AutoCAD expert and, to be honest, the thought of using a command-line input to perform operations and using LISP as a programming language seem a bit, well, 1990s. But who am I to say? AutoCAD is doing very nicely thank you, and there are many happy users out there.

This is a simple plate with a hole and a cylinder in the default wireframe view. Note the rather nice ‘ribbon’ menu which is an option over the older ‘classic’ menus.

Design in 2D


CorelCAD works in AutoCAD’s native DWG format and you can import and work with AutoCAD drawings directly. That’s a big plus – there are many manufacturers who produce CAD drawing in DWG format for download and incorporation into your designs. But you can also import and export to CorelDraw’s native CDR format. For me, the export worked ok, but I had difficulty with importing my existing mechanical designs. CorelCAD did import them – but the dimensions were not correct (they were page dimensions, not the dimensions I had specified in CorelDraw) and in some cases the relative sizes were not correct. I was hoping that I could import my existing CorelDraw diagrams and start working on them immediately. In the end I decided that it would be simpler to start again.

With any CAD package there is going to be a learning curve. By all accounts CorelCAD is simpler to learn than AutoCAD but, even so, it’s a complicated and powerful design package and I found that it took me some time to get into producing even simple 3D objects. One of the rather strange things about CorelCAD is the help system. It really is the good old fashioned Windows XP style help. It’s comprehensive, true – but compared to the help provided with AutoCAD Fusion 360 or SolidWorks (with good short video tutorials and well laid out HTML pages on the web) it looks pretty antiquated.

2D drawings are easy, though. Even though the menus are different, I found that I could re-use much of what I knew from CorelDraw to lay out and align rectangles, etc. and specify the distance between various components – the dimensioning tools are first rate. I found the ‘Quick Input’ mechanism, where you can specify the dimensions of, say, a rectangle, on the fly to be particularly useful. As you might expect, the ability to accurately produce 2D layouts and plans is in a different ballpark to CorelDraw, and having using CorelCAD for drafting and creating 2D designs, I’d be reluctant to go back.

You can ‘shade’ the wireframe to get an idea of what the finished item will look like. It’s ok but not wonderful.

Into the Third Dimension


In addition to 2D work, CorelCAD also allows you to work with 3D objects. You can extrude a 2D surface to produce a 3D box, create spheres, wedges, cylinders, etc. and you can operate on them to generate holes and interiors. You can also create fillets and so on and ‘loft’ surfaces to generate 3D objects. I’m no architect, but I can see how this will work well for architectural designs in the traditional AutoCAD manner.

However, for 3D mechanical designs, there are some issues.

The first problem I had was to create a hole. Simple holes are fine, if a little unintuitive (you subtract a cylinder from a solid object), but what about an M3 machine screw hole with an 82 degree countersink? Or an M6 counter bore? Not so easy – ideally, I want a ‘hole’ menu which allows me do a number of common hole type operations. I would think that it is possible to create functions like this in CorelCAD by programming (in LISP) a routine that does exactly what you want. But I want to get on with designing my machine – not writing LISP scripts.

CorelCAD mainly operates in wire-frame mode. Typically, you would start off with a 2D ‘layout’ of a 3D design, and then extrude and move parts to where they need to be, while the display remains in wire-frame. Wire-frames, though, strike me as something of a throwback to the days when graphics cards and CPUs were not powerful enough to fully render 3D objects in real time. Times have changed and I prefer working in a fully rendered, rotatable 3D view all the time as in the Solidworks/AutoDesk Fusion 360  type of 3D CAD software. With these you create a 2D ‘sketch’ on any surface of an existing fully rendered 3D object and extrude 3D shapes from the sketch – to my mind a much more intuitive approach.

The new QuickInput system allows you to specify dimensions ‘on screen’ rather than using the command line.

An important feature that CorelCAD is missing for 3D work is ‘assembly’. In producing a full 3D ‘model’ of a robot, say, you would typically have a number of parts – ‘components’ – designed separately; and you then want to bring them all together as a fully functional composite object. So, you really want to be able to select a gear shaft, say, and the center of a the hole in a gear and ‘join’ them, so that they align exactly, can rotate freely about a common axis and can then be moved and placed as one component. CorelCAD does have object ‘snaps’ where you can move an object to, for example, a position close to the middle of a line and it will snap to the mid-point. But this isn’t really the same as an assembly function. For me, assembly is essential. In researching which CAD package to use for designing robots,  I’ve tried several CAD packages without assembly and it takes far longer to produce a workable model than with a CAD package with it.

This is an example of a standard CAD file made available for download by a manufacturer (in this case igus  - www.igus.com). Because CorelCAD works in native DWG format, importing files like this works perfectly.

Overall


If you want to use CorelCAD for architecture, planning, office layouts or individual component design, assembly may be pretty much irrelevant. CorelCAD is excellent at producing 2D drawings and plans and it’s also good at 3D architectural designs, but there are better products available for complete mechanical designs.

But there is one more feature of CorelCAD that you might like to consider: it has a ‘perpetual’ license. Many CAD systems – AutoCAD and SolidWorks, for example – require you to pay a yearly rental or subscription fee. For this you get the benefits of bug fixes, support and the latest releases of the software. You might think (as I do) that this is fine for the software vendor but not so good for those people who just wants to purchase something once and may consider upgrading after a few years. The CorelCAD perpetual license means that once you buy it, it’s yours to keep.

To get a really good view of what you’re working with, you have to ‘animate’ the view. This is what I would like to work in all the time, but when you ‘animate’ a model, all you can do is rotate it and admire it. You cannot alter it while in this mode.

The Good

1)    excellent  at 2D designs, layouts, drafting and drawings
2)    works in DWG as native format and is cheaper than AutoCAD
3)    imports and exports to CorelDraw and other Corel products
4)    perpetual software license

The Bad

1)    importing from CorelDraw did not work well for me
2)    mainly wire frame mode
3)    old fashioned help system with limited tutorials
4)    no assembly

…and the ugly?


No. CorelCAD is fine, as long as you are aware of its strengths and its limitations and use it appropriately. It is an excellent CAD package aimed at the AutoCAD (as opposed to full blown 3D design like SolidWorks) market. If you mainly want to produce 2D designs and 3D architectural drawings, it will serve you well. The 3D design functionality is adequate but if 3D mechanical design is your main purpose, there are better, more modern alternatives. But it’s a lot cheaper than AutoCAD (which currently costs £1,506 per year!) and it has a perpetual license. In short, I’m happy to design components and produce 2D layouts with CorelCAD, but I wouldn’t want to design a jet engine in it!

Thursday 2 November 2017

Constructors in C#

C# (C-Sharp) is an object oriented programming language or OOP for short. Many modern language such as C++, Objective-C, Java, Ruby and Python are also object oriented. You can think of an object as a sort of package that wraps up data – that’s variables, such as strings and numbers – and behaviour – that’s functions or methods that do something, often by manipulating an object’s internal data.

The definition of an object is called its class. You can think of a class as a blueprint for an object. It’s just like the blueprint for a car. The blueprint defines all the fundamental features of a car but you can’t actually drive the blueprint. To use a car you have to create one based on the blueprint’s definition. That’s what you do in programming too. You write a class and you create usable objects from it. In fact, just as you can create many cars based on a single blueprint, so you can create many objects based on a single class.

When you create a new object from a class, you can call that class’s constructor to initialize the object. A constructor is a method that has the same name as the class itself. This class is called MyClass, so the constructor method will also be called MyClass.

public MyClass( ) {
}

The constructor has to be public – that is, it has to be visible to code outside the class itself – because clearly I need to call the constructor method from other parts of my program, whenever I want to create a new MyClass object.

A constructor doesn’t have to have any parameters. However, when an object has some internal fields, it is quite common for the constructor to define a list of parameters to initialize those fields. In that case, when you invoke the constructor, to create a new object, you would need to pass the appropriate arguments to initialize those fields. When an object descends from another object and the object from which it descends has a constructor that initializes some fields, the descendent class’s constructor can call the ancestor class’s constructor, passing to it any arguments required by the ancestor constructor to initialize its fields. It does that by putting a colon after the parameter list of the constructor, then the keyword base, then a comma-separated list of arguments between parentheses.

This short video (taken from my course ‘Learn C# Programming (in ten easy steps)’ gives a few more details about C# constructors.


This course was first created in 2012 but now, in 2017, it has been completely remade. Every single video has been re-done and no less than 86 new video lessons have been added. What’s more, students can also download the entire version 1 of the course (almost 4 more hours of video) as an added bonus. This is what the course contains:

  • 117 video lessons
  • 7 hours, 7 minutes of video
  • 32 sample projects
  • 10 quizzes
  • 89-pages of pdf documentation
  • PLUS: The entire version 1 course as a free download!

The regular price for this course is $145. But use the link below to sign up for just $35 (valid only until the end of 2017, so don’t wait!)

https://www.udemy.com/learn-c-sharp-programming-in-ten-easy-steps/?couponCode=35DOLLARDEAL

Wednesday 1 November 2017

C Programming - Arrays, addresses and pointers

#include <stdio.h>

int main(int argc, char **argv) {
char str1[] = "Hello";
char *str2 = "Goodbye";
// str2 = &str1;
// str2 = str1;
printf("%d %d %s\n", &str1, str1, str1);
printf("%d %d %s\n", &str2, str2, str2);
return 0;
}

Let’s now look at how pointers and addresses work in C – and why arrays are special. In the code shown above I declare two string variables, str1 and str2. You can create string variables using either syntax but you need to understand that these two variables are by no means the same as one another. The first, str1, declared with a pair of square brackets is an array. The second, str2, declared using the star operator, *, is a pointer. As we know (see previous article), an array and an address are equivalent. So str1 is the address at which the array of characters in the string “Hello” are stored. But str2 is a pointer whose value is not the string “Goodbye” but the address of that string. So str2 'points to' the address at which the characters “Goodbye” are stored.

This should be clearer when you run the code.

When displayed as an integer value, the address of str1 (returned by the & address-of operator) is the same as the value of the variable str1 itself. That’s because str1 is an array - and an array is, in effect, an address.

But the address of str2 (returned by the & address-of operator) is different from the value of the str2 variable. Here the address gives us the location in memory of the pointer variable, str2. But the value of that variable is the address of the array of chars to which it points.

str1 is the location of the start of this array of characters, “Hello”, in computer memory. The address of str1 is the location where that string of chars begins.

But the value of the pointer variable str2 is a number that gives the location of the start of the array of characters “Goodbye” in computer memory. The address of str2 is the location where the str2 pointer variable is stored – and if we just want to get at data in the array, the address of the pointer variable itself is of no interest to us. For now, I’m only interested in the address of the array to which this pointer points. The value of str2 is the address of that array: the address of the first character in the string “Goodbye”.

The video below is taken from my online course, Advanced C Programming: Pointers. You can subscribe to this course, for a limited period, and save 63% by clicking this link. This lets you join up for $35 (regular price is $95): https://www.udemy.com/advanced-c-programming-pointers/?couponCode=CPOINTERS2017