Constraints CATIA macro

Constraints CATIA macro

While searching the web I found one very interesting macro for me. So I decided to write code for constraints CATIA macro.

powercopy and macro

In the video above you can see a lot of different CATIA macros. All of these macros are based on good ground models and templates. Therefore if you want to have good optimization you must have good templates and basic models. Hence in this post, we want to recreate macro from 0:50-1:00 min of the video. So what this constraint CATIA macro does? It creates constraints for all points inside sketch and round them with the chosen number. I do this operation all the time but manually. Grid for screws is very important, consequently, you can have a problem in production. Certainly with this macro you can easily maintain that problem. With a little bit different code from this you can also check your constraints if they are divided with 10, 5, etc.   This is Visual Basic application but we can make it also with CATScript. 

Recording macro

Best way to start making these constraints CATIA macro is to record one. You need to make two constraints for the point inside the sketch.  

constraints CATIA macro

Certainly, this recorded macro can help a lot. We just need to change that names, insert some sort of selection and for a loop.

Editing recorded macro

This is our final code hence just copy and paste it. So if you want to use this macro make a sketch and few points inside. From the sketch environment run these constraints CATIA macro like in the video below.

You can copy-paste this macro code and use it.

If you have any issues feel free to contact me.

6 thoughts on “Constraints CATIA macro

    • December 27, 2018 at 9:29 pm
      Permalink

      Hi, well i can understand it, but it can be very helpful once you got it.
      If you have any questions feel free to ask.

      Reply
  • July 21, 2020 at 3:51 am
    Permalink

    im getting microsoft vb script compilation error
    description :expected end of statement
    satement:dim num as integer
    line:4
    column:8

    Reply
    • July 21, 2020 at 8:47 pm
      Permalink

      Hello, there is no problem with this line Dim num As Integer. Maybe sowhere else in the code. Can you send me the full code to check it.

      Reply
  • November 28, 2023 at 3:03 pm
    Permalink

    Hi, I am trying to automate constraints in the product document (i.e., assembly). I use the following code to import the parts:
    products2.AddComponentsFromFiles arrayofvariantofbstr1,”All”
    If I want to create a reference1 using a geometrical point inside the inserted part, how can I do that using macro? The inserted part has only one geometrical point in it. Thanks!

    Reply
    • November 29, 2023 at 8:17 am
      Permalink

      Hello, I didnt make assy constraints like that. I always use one coincidence constraint. For that you will need axis system in both parts, and connect those two. In this case it will be much easier to create assy constraint. I hope this help.

      Reply

Leave a Reply

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