Close

Alright, Let's get the Party Started!

A project log for Tiny CAD

Tiny houses are all the rage. Yet CAD software is expensive. So let's give some people a head start on affordable housing.

glgormanglgorman 06/16/2023 at 21:470 Comments

Here is a screenshot from a program that I have been working on for what seems like forever, and if you don't know by now, I despise Java, JavaScript, and a bunch of other madness. Well now you know, in any case.  Real programmers, IMHO program in real languages, like C, C++, Lisp, Pascal (which is a subset of ADA), and of course let's not forget FORTRAN and assembly, even if I have long since forgotten most of my FORTRAN.  Oh, well.  In any case, let's look at how I decided to lay out a simple wall in C++.

// construct a temporary reference stud and make copies of that
// stud as we need ... future version - make all  of the studs
// all at once and put them in a lumber pile with painted ends
// then animate construction appropriately.  Uh, huh - sure
// "real soon now" ... 

void simple_wall::layout_and_construct_studs ()
{
    int number_of_studs;
    _vector w1,w2;
    rectangular_prism    reference_stud (STUD_WIDTH*FEET_TO_CM,STUD_DEPTH*FEET_TO_CM,(m_height-STUD_WIDTH)*FEET_TO_CM);
    reference_stud.m_color = COLOR::yellow;
    reference_stud.m_bFillSides = true;
    m_span = _vector::length (m_end [1] - m_end [0]);
    _vector direction = _vector::normalize (m_end [1] - m_end[0]);
    reference_stud.set_orientation (0,0,arccos(direction[0]));
    number_of_studs = 1+(int)floor (m_span/(FEET_TO_CM*m_stud_spacing));    

    int k;
    for (k=0;k<number_of_studs;k++)
    {    
    w1 = m_end [0]+direction*(k*FEET_TO_CM*m_stud_spacing);
    w2 = w1 + _vector (0,0,m_height*FEET_TO_CM);
    reference_stud.set_position (_vector::midpoint (w1,w2));
    reference_stud.calculate_vertices();
    m_studs.push_back (reference_stud);
    }

    //    this is the bottom plate and the top plate
    m_bottom_plate.m_size = _vector (m_span,STUD_DEPTH*FEET_TO_CM,(STUD_WIDTH-STUD_GAP)*FEET_TO_CM);
    m_bottom_plate.SetObjectColor (COLOR::green);
    m_bottom_plate.set_position (_vector::midpoint (m_end [1],m_end [0]));
    m_bottom_plate.set_orientation (reference_stud.get_orientation());
    m_bottom_plate.calculate_vertices ();

    for (k=0;k<2;k++) {
    m_top_plates[k].m_size = m_bottom_plate.m_size;
    m_top_plates[k].SetObjectColor (COLOR::yellow);
    m_top_plates[k].set_orientation (reference_stud.get_orientation());
    m_top_plates[k].calculate_vertices ();
    m_top_plates[k].set_position (_vector::midpoint 
    (m_end [1],m_end [0])+_vector (0,0,m_height*FEET_TO_CM));
    }
    m_top_plates[1].m_position += _vector (0,0,STUD_WIDTH*FEET_TO_CM);
}

 OK - so there are about 1000 lines of this stuff, just to lay out a simple floor plan, and maybe another 30 thousand or so lines that do the tensor math stuff for the 3-d calculations, with either Open-GL or GDI-based rendering.  Haven't really put much thought into Microsoft's "Write Once Run Anywhere" concept that is supposed to be able to take C/C++ code and turn it into Java-Script, or is it TypeScript, or was that something else that I never really got into; like how some people might get DOOM running on a Cannon printer, that is with some kind of code conversion tool.

O.K., in any case - a simple stud wall is pretty much a slam dunk.  Figuring outdoors in windows is another matter.  Then, of course, there is roofing.  Sometimes, it is much simpler to just build the real thing.  Working out gables, especially if you want a complex roof design, ouch - now we have to get into some kind of theory of intersecting planes, and which ones have priority, etc., and then there are the rafters, and the cross bracing, and so on; figuring out what intersects what.  Some things are quite easy in Vectorworks or Autocad, except for the $$$ part.

Yet this should be really simple to conceptualize, I mean for a simple house, if you have a floor plan, shouldn't you be able in the world of "object-oriented programming" just to be able to tell the walls and all of the rest, to just "build themselves?  Oh, and then there are stairs, and stuff like that, and kitchens, and plumbing, etc.  No free lunch there either.

I wonder what GPT knows about basic framing?  Or else will Elon's robots be up to the task of taking on "simple" light wood frame construction?

Discussions