Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

CATIA vb.net Change axis direction

Status
Not open for further replies.

TiagoFigueiredo

Industrial
May 22, 2013
494
PT
Hello,

I'm creating a macro in visual studio, Vb.net, and in a certain point, I need to change the z axis direction of an axis system.

in vb6 i used like this.

axisSystems1.ZAxisType = catAxisSystemAxisOppositeDirection

in vb.net it doesn't work.

Any idea ?

Tiago Figueiredo
Tooling Engineer
 
Replies continue below

Recommended for you

If you use late binding, you have to replace constant catAxisSystemAxisOppositeDirection with a real value. In this case according catia reference catAxisSystemAxisOppositeDirection = 2.

Tesak
- Text along a curve for Catia V5
 
Don't now why, it works with VB6, don't work in vb.net....

Any idea how to solve?

Tiago Figueiredo
Tooling Engineer
 
Hi,

You have to declare

Capture_m9mmad.png


Regards
Fernando

- Romania
- EU
 
Now i don't have my computer with me. But when I have it with me, I Will try it. Many thanks.

Tiago Figueiredo
Tooling Engineer
 
I still don't have solution for this.

In my web search i found this:

Code:
Set oAchs = oPart.AxisSystems.Add()
    
    Set oUrsprung = oPart.Parameters.Item("Startpunkt")
    Set oZ_Richt = oPart.Parameters.Item("Linie-normal")
    
    oAchs.OriginType = catAxisSystemOriginByPoint
    oAchs.XAxisType = catAxisSystemAxisSameDirection
    oAchs.YAxisType = catAxisSystemAxisSameDirection
    oAchs.ZAxisType = catAxisSystemAxisSameDirection
    oAchs.IsCurrent = False
    
    oAchs.OriginPoint = oPart.CreateReferenceFromObject(oUrsprung)
    oAchs.ZAxisDirection = oPart.CreateReferenceFromObject(oZ_Richt)

Wich is almost the same that i'm using. I still don't have found my mistake.


In module i have made the publication

Public Const catAxisSystemAxisOppositeDirection As MECMOD.CATAxisSystemAxisType = 2

then in the public sub


i have made this:

Code:
Dim axisSystems1 = selection1.Item(1).Value
        axisSystems1.Name = "Screw hole direction." & Num_hole
        axisSystems1.ZAxisDirection = catAxisSystemAxisOppositeDirection


I need help!!!

Tiago Figueiredo
Tooling Engineer
 
I forgot to say, that this axis system is located in a Geometrical set.

This works in catvba. But I still don't know why don't work in vb.net.

Tiago Figueiredo
Tooling Engineer
 
I saw on stackoverflow that you cannot create a new axis. Hope it will help you a little bit.

Code:
        Dim partDocument1 As Document
        partDocument1 = CATIA.ActiveDocument

        Dim selection1 As Selection
        selection1 = partDocument1.Selection

        selection1.Search("Name=*Absolute' 'Axis' 'System*,all")

        If selection1.Count = 0 Then

            Dim part1 As MECMOD.Part
            part1 = partDocument1.Part

            Dim axisSystems1 As MECMOD.AxisSystems
            axisSystems1 = part1.AxisSystems

            Dim axisSystem1 As MECMOD.AxisSystem
            axisSystem1 = axisSystems1.Add()

            Dim arrayOfVariantOfDouble1(2)
            arrayOfVariantOfDouble1(0) = 0.0
            arrayOfVariantOfDouble1(1) = 0.0
            arrayOfVariantOfDouble1(2) = 0.0
            axisSystem1.PutOrigin(arrayOfVariantOfDouble1)

            axisSystem1.XAxisType = catAxisSystemAxisByCoordinates

            Dim arrayOfVariantOfDouble2(2)
            arrayOfVariantOfDouble2(0) = 1.0
            arrayOfVariantOfDouble2(1) = 0.0
            arrayOfVariantOfDouble2(2) = 0.0
            axisSystem1.PutXAxis(arrayOfVariantOfDouble2)

            axisSystem1.YAxisType = catAxisSystemAxisByCoordinates

            Dim arrayOfVariantOfDouble3(2)
            arrayOfVariantOfDouble3(0) = 0.0
            arrayOfVariantOfDouble3(1) = 1.0
            arrayOfVariantOfDouble3(2) = 0.0
            axisSystem1.PutYAxis(arrayOfVariantOfDouble3)

            axisSystem1.ZAxisType = catAxisSystemAxisByCoordinates

            Dim arrayOfVariantOfDouble4(2)
            arrayOfVariantOfDouble4(0) = 0.0
            arrayOfVariantOfDouble4(1) = 0.0
            arrayOfVariantOfDouble4(2) = 1.0
            axisSystem1.PutZAxis(arrayOfVariantOfDouble4)

            part1.UpdateObject(axisSystem1)
            axisSystem1.IsCurrent = True


            part1.Update()

Regards
Fernando

- Romania
- EU
 
I Fernando,

Yes, i'm having some problems with it. I still don't understand why, but definitely, there is something wrong with my code. I was focus in changing direction of the Z axis, with no results. Then I remember to create a new axis system, and no results as well. So in cooperation with a member of this forum, I decided to compile the code to a new project in visual studio, just to focus on my problem. With this new code it works real fine. So definitly there is something wrong with my code. So I will start it from scratch.

Tiago Figueiredo
Tooling Engineer
 
I everyone. I found my mistake. And what a stupid mistake.......

When i made the search to find my axis system. I used the search method because isn't inserted in axis system colector.

Code:
selection1.Search("Name='Screw hole direction' &  CATPrtSearch.AxisSystem,sel")

the name of the axis it was wrong.

Screw hole direction

what a stupid thing....

I never suspected that the search was wrong, and never debug it until now...

Thanks by your help

Tiago Figueiredo
Tooling Engineer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top