DesignCAD User Forum

General DesignCAD Topics => Looking For Help? => Topic started by: DBS99 on December 18, 2017, 07:17:10 PM

Title: Need help with programming in DesignCAD
Post by: DBS99 on December 18, 2017, 07:17:10 PM
I am using DesignCad 3D Max 23.  I just recently started doing some pretty intense macro writing using Basic Cad and would like to do more sophisticated things.  I have a lot of experience coding with VBA in Excel and am wondering is there a way for me to do macros in Design Cad using VB or a similar language rather than being limited to using Basic Cad macros.  For example, I used a macro to insert parallel lines of even spacing and trimming them to a pre-existing curved line above them and a curved line below them.
It worked okay but I believer it would have worked better if I could have named the curved lines and named each line my macro inserted and them figured out way to call each entity by name and trim the new lines to he curved lines.  Not sure what that code would look like but I do know I could do more by being able to write more spohistcated code.  I just don't know how to do that with Design Cad.
Title: Re: Need help with programming in DesignCAD
Post by: Lar on December 19, 2017, 06:24:09 AM

Maybe this link can help you: (

I know you can use VB for macros but I don't use it myself. The member who I know to us it the most (Prl) hasn't been heard from on this forum for a few years now. Other than him, Droll Troll would be the expert on everything dcad.

One thing I found very strange about non-basiccad macros was many years back when someone (it may have been Prl) was complaining that his macros were very slow. I responded that how can this be because my layer macros for example (where I would run a macro to write another macro that saved the layer statuses as they were right then and later when I needed that layer setup again I would run the 2nd macro) would run through all two thousand layers before my mouse finger relaxed from double clicking the macro name in the 'open file' dialog box. Come to find out he was using VB or something and all that compiling stuff slowed down his macros considerably. I don't know if it's any faster now'a days. One thing that did charm me about VB was the ability to create your own dialog boxes, which basiccad totally lacks. Another thing is every VB macro requires a 2nd file for some reason, but I guess you are familiar with all that.

ps: my macros that actually draw stuff and perform 3d tasks also execute very quickly...
Title: Re: Need help with programming in DesignCAD
Post by: DBS99 on December 19, 2017, 07:53:29 PM
Thanks for the reply Lar.

I am not opposed to BasicCad macros at all and find them quite useful.  However as a newbie, my belief is they are limited to existing DesingCad commands and I am hoping by using VB I can do tasks that are not possible using existing DesignCad commands.  For example, the only command I know for trimming or extending one line to another requires you to select the command first and then select the lines.  For what I need to do, it would work much better (I think) to select the two entities (in this case lines) by name and then trim or extend one to the other.  If there is a DesignCad command that achieves this and I can call that command up in a BasicCad macro, I am fine with using that method.  I have a Basic Cad macro I wrote that is inserting a lot of vertical lines automatically and I need to trim or extend them to existing curves running mostly horizontal and then get the endpoint coordinates of all the lines I added and trimmed.  I have exrything working great except for some lines end up being outside the horizontal curves and some end up between them.  I do not know ahead of time which ones will fall into each of these categories, so trying to select the trim command ahead of time and then select points on the curves does not work real well because the curves are already existing in a drawing I am getting from a customer.
Title: Re: Need help with programming in DesignCAD
Post by: BlankMan on January 10, 2018, 06:44:16 AM
My current main project in DesignCAD MAX 2018. An electronics project enclosure, Completely drawn using BasicCAD. Just over 4,900 lines of code. Turns out to be the most lines of code ever for a DC drawing in 25+ years of doing this.

Done this way for prototyping using variables for the various component dimensions so the part dimensions, location, and orientation can be easily changed as needed.

Title: Re: Need help with programming in DesignCAD
Post by: Dr PR on January 10, 2018, 10:20:23 AM
Just curious - any idea how long it took to write those 4900 lines of code?

Title: Re: Need help with programming in DesignCAD
Post by: BlankMan on January 12, 2018, 01:41:41 PM
I started it around the 27th and it progressed from there. Been many many incarnations and adjustments made and changes as the electronic design changed. Probably made 8 or so on the printer so far, one bottom is printing now. Not really done yet either. Have all the components now for test fits though. Have to move the fan to accommodate a bracket that will attach to the top for a touchscreen display which still needs to be drawn.

BTW This all has been done by subtraction only, not a single add. Whereas in the past a combination of both were used. But DCAD still manages to screw up the OBJ and STL exports. Cannot do them correctly.