Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cotation in automatic all objects inside sketches of a part

Status
Not open for further replies.

Jeremy456

Mechanical
May 3, 2023
2
Hi all!

I'm new to doing VBA for Catia, so sorry in advance if the subject has already been covered I didn't find something similar. Also sorry for my english mistakes, I'm not english native.

I am actually trying to figure out how to do the cotation of lines/points in all of my sketches in a part.

Currently I am doing my cotation for all my geometries according to my dimensionning but all my different axis and points at the edges of my lines/axis I'm not coting them. I would like to implement a little tool in order to check all the object (lines/axis and points) that are not coted and then do an automatic cotation horizontal and vertical in order to have them iso constrained.

You have some clue about the builtin functions I can use?

Thanks a lot!!!
 
Replies continue below

Recommended for you

Sorry, but what do you mean by Cotation? Can you explain the sequence of command if you were to do it manually?
 
You mean Auto constraint?


If it's this, try this code in vb.net. If you want vba, you will need some small changes

Code:
Public Sub Auto_Constraint()
        selection1.clear
        selection1.add(Sketch_edit)
        selection1.Search("Type=*,sel")
        CATIA.StartCommand("Auto Constraint")

        AppActivate("CATIA")

        CATIA.RefreshDisplay = True
        SendKeys.Send("{ENTER}")

    End Sub


Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
Hi there,

Thanks a lot for answering!

@sanganaksakha: by Cotation I meant putting dimension like from a point A to point B with a value.

@TiagoFigueiredo: The Auto Constraint method works well when I do it manually, this function is good yes. Unfortunately I'm not good enough on how to figure out how to launch your vb.net code... I was used to launch Macro from Catia Tools/Macro window. I tried to put the code in a new macro but not working.

I try to modify your code as follow to have it in VBA but I think I did more wrong than good, sorry I'm really not from the coding domain.

Code:
Public Sub Auto_Constraint()
    Selection.Add (Sketch_edit)
    Selection.Search ("Type=*,sel")
    CATIA.StartCommand ("Auto Constraint")
    CATIA.RefreshDisplay = True
    SendKeys ("{ENTER}")
End Sub


I found the window VBA and tried to create a new module and paste the code above also but not working neither. I get the error since the begining with "sketch_edit" empty.
 
To have the Sketch_edit variable, you will to have the following. Before that code, you will need to determine which sketch is in edition. So it's supposed that you have one sketch in edition.

Code:
Public Sub Det_Sketch()
        

        'Condition if sketch is on edition
        Workbench = CATIA.GetWorkbenchId
        If Workbench = "CS0WKS" Then
            CATIA.StartCommand("Fit All In")
            CATIA.StartCommand("No 3D Background")
            CATIA.StartCommand("Fit All In")
            selection1.Clear

            Do Until selection1.Count > 0
                selection1.Search("Sketcher.Origin,scr")
            Loop

            Sketch_edit = selection1.Item(1).Value.Parent.Parent.Parent

            selection1.Clear

            CATIA.StartCommand("Low light")

            CATIA.RefreshDisplay = True

            CATIA.StartCommand("Previous View")
        Else

            MsgBox("There is no sketch in edition")

        End If

        selection1.clear
    End Sub

Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor