×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

CATIA vb.net Change axis direction

CATIA vb.net Change axis direction

CATIA vb.net Change axis direction

(OP)
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

RE: CATIA vb.net Change axis direction

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

Tesak
http://scripts4all.eu/txtoncurve/ - Text along a curve for Catia V5

RE: CATIA vb.net Change axis direction

(OP)
Don't now why, it works with VB6, don't work in vb.net....

Any idea how to solve?

Tiago Figueiredo
Tooling Engineer

RE: CATIA vb.net Change axis direction

(OP)
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

RE: CATIA vb.net Change axis direction

(OP)
I still don't have solution for this.

In my web search i found this:

CODE --> Vb

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 --> vb.net

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


I need help!!!

Tiago Figueiredo
Tooling Engineer

RE: CATIA vb.net Change axis direction

(OP)
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

RE: CATIA vb.net Change axis direction

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

CODE --> vb.net

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

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: CATIA vb.net Change axis direction

(OP)
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

RE: CATIA vb.net Change axis direction

(OP)
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 --> vb.net

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources