Q and A about Alireza Reihani’s CATVBA Project

I’ve put a lot of time and energy into trying to teach CATIA users how to program macros. I absolutely love hearing about success stories of students who have been able to take the knowledge gained from my book or website and transform it into something awesome. And that’s exactly what Alireza Reihani did. Check out the video of the project embedded below then read our Q/A discussion about how it was made.

ER: Thanks for taking the time to answer a few of my questions.


AR: Thanks a lot, you gave me energy.


ER: How much programming experience did you have before tackling this impressive project?


AR: I have more than 15 years’ experience in programming for AutoCAD. Six month ago I started to learn programming in CATIA and really this is my first experience in CATIA.


ER: Why did you decide to make this program?


AR: One year ago (10 July 2014) I immigrated to Canada (Skilled Worker) after three months I found my first job as a Designer/Draftsman. Now I work with Solidworks and AutoCAD. I can work with CATIA better than Solidworks and here (Montreal) is an Aeronautic pole where more than 200 company works with CATIA. In this way I want to show them my ability, maybe it will be useful.


ER: And why create a flower of all objects or shapes?


AR: Because many people like flowers, they are colorful and beautiful. In addition, I think components of a flower are suitable for being produced in GSD workbench.

catia flower

ER: How long did it take you to complete?


AR: I finished this program in 3 weeks. I decided 3 times to stop programming so I could solve problem and I continued!!!


ER: What are some of the problems you ran into and how did you solve them?


AR: One of the solutions is not logic: for creating ovary (Blend) I need two circles; lower circle is upper boundary of stem (Sweep circle), I couldn’t get it then I used Intersection between stem and a plane. It solved my problem but in some cases there is more than one answer for intersection and program stops.


For creating holes in ovary I projected a circle on bump surface and by Split I created holes. I couldn’t create all holes at one command, I think this problem is related to CATIA and not VBA (after projecting all holes on the bump when splitting a massage appears that all of curves are not on the surface!). Then I used a For Next loop to create holes!


I didn’t send data from form to main subroutine (Flower) by arguments, now this subroutine reads data directly from form (variable=frmFlower.textboxxxx.text) and this is not logic in addition I could put this subroutine in the form not in a module.

vba userform in catia v5

ER: What commands or steps did you use in the process?


AR: As you can see in the description of the video, for this project I learned more than 30 different commands before and finally I combined them.


The steps of the drawing are:

(These steps are a little different with that I have written in Comment text of program)

‘1- Create Stem:

                ‘1-1)  Create Geometrical Sets

‘1-2) Create offset distance plane

‘1-3) Create Sketch in that plane (Create two Arcs (Center Point, Radius and angles))

‘1-4) Create Join Sketch

‘1-5) Create Sweep Circle

‘1-6) Coloring Sweep

‘2- Create Ovary:

                 ‘2-1: Create Extremum Point of Sketch in +Z

                 ‘2-2: Create Plane perpendicular to Sketch

                ‘2-3: Create Intersection (Instead of Boundary of Sweep)

                ‘2-4: Create Offset (Parallel) Plane

                ‘2-5: Create Circle (Center point and Radius)

 ‘2-6: Create Blend

                ‘2-7: Create Sketch2 Projection

                 ‘2-8: Create Fill

                 ‘2-9: Create Bump

                 ‘2-10: Create Hole

                                ‘2-10-1: Create Hole Center Point

                                ‘2-10-2: Project Hole Circle on the Bump

                                ‘2-10-3: Split

                 ‘2-11: Create Fillet

                ‘2-12: Coloring Fillet

‘3- Create Flower

                 ‘3-1: Create Extremum Point of Intersection (+Y)

                 ‘3-2: Create Plane Perp. to Sketch2 through Extremum Point

                 ‘3-3: Create End Point of Flower

                 ‘3-4: Create Flower Line (Point to Point)

                ‘3-5: Create Plane Perpendicular to Flower Line through Start Point, End Point and 5 distances

                ‘3-6: Create 7 Arcs in each Plane

                ‘3-7:  Create First Point, End Point and Extremum Point (-Z) of each arc

                ‘3-8: Create 3 Splines as Loft Guides

                ‘3-9: Create Loft (First Outer Petal)

                ‘3-10: Create Circular Array of Petal

                ‘3-11: Create Scale of First Petal

                ‘3-12: Create Create Circular Array of Inner Petal

                ‘3-13: Coloring of Petals

                ‘3-14: Hiding Some Objects and Geometrical Sets



ER: What resources did you use to help solve all your problems?


AR: Seven months ago at first I bought this book “CATIA Macro programming with Visual basic script” by Dieter Ziethen and Kyle Brand. It’s like a reference book – not a guide for starting! In addition, you cannot learn about working with windows, Views, Drafting Workbench and connection with other programs (like excel or Access).


Then I bought your book. It’s great. In fact, you teach how to be a programmer. My third reference (as you mentioned in your book) was CATIA Macro Recorder. But in this project for one or two commands, Macro Recorder couldn’t record anything!


ER: I’m glad my book and website were able to help! Thanks again for taking the time to answer my questions and for agreeing to share your amazing project with everyone.


AR: My pleasure and thanks for your useful book. Your book is great and it helped me in starting of learning macro programming in CATIA.


ER: Download the CATIA part and the VBA code using the links below:


Download Alireza Reihani’s Flower Creator.CATPart

Download Alireza Reihani’s Project Code.CATVBA


If you have a CATIA VBA project you wouldn’t mind sharing feel free to contact me as I would love to hear all about it. Programming is used in many different ways, often in methods you wouldn’t expect.




Add a Comment

Your email address will not be published. Required fields are marked *