×
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

Macro to create a point like button

Macro to create a point like button

Macro to create a point like button

(OP)
Hello
I am new on CATIA and i recorded this macro when i created 1 point but now i want that the macro ask me to select the surface and after tell me to click on the surface to create the point (like if i am creating 1 point with CATIA button)
I think that i need to change the red texto and i saw that i can use GetSightDirection but i dont know how.
Can someone help me with this?

Rúben Silva

CODE --> V5

Language="VBSCRIPT"

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part


Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(-0.713634, -0.684806, 0.147534)
[/color]

Set axisSystems1 = part1.AxisSystems
Set axisSystem1 = axisSystems1.Item("axi")

Set reference1 = part1.CreateReferenceFromObject(axisSystem1)
hybridShapeDirection1.RefAxisSystem = reference1

Set bodies1 = part1.Bodies
Set body1 = bodies1.Item("bp50")

Set shapes1 = body1.Shapes
Set solid1 = shapes1.Item("Solid.106")

Set reference2 = part1.CreateReferenceFromBRepName("RSur:(Face:(Brp:(Solid.106;%24);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", solid1)
Set hybridShapePointOnSurface1 = hybridShapeFactory1.AddNewPointOnSurface(reference2, hybridShapeDirection1, 0.000000)

Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("MACRO_AUXILIAR")
hybridBody1.AppendHybridShape hybridShapePointOnSurface1

part1.InWorkObject = hybridShapePointOnSurface1
part1.Update 

End Sub 

RE: Macro to create a point like button

read the online doc about Selection.IndicateOrSelectElement3D

Eric N.
indocti discant et ament meminisse periti

RE: Macro to create a point like button

(OP)
There are a problem, as i can see, i can only use Selection.IndicateOrSelectElement3D on planar Geometries, that limit alot

RE: Macro to create a point like button

Can you ask the user to create the point first then just do a selection in the script?

Eric N.
indocti discant et ament meminisse periti

RE: Macro to create a point like button

(OP)
I can do that but i was thinking do a macro because i need to get I,J,K of Normal and with the macro i could save the coordenates of the point/points and the surface name.
I could create the point/points first but after that i dont know to create a macro to get Normal.
Do you know any other way to get the normal of 1 point\coordenate on surface?


RE: Macro to create a point like button

with point and surface, create (by macro) the line normal to surface at the point and get ijk from line...

Eric N.
indocti discant et ament meminisse periti

RE: Macro to create a point like button

(OP)
but if i create a point just with selection, i can't do a macro to create a line normal to surface because i dont have the number\name of the surface

RE: Macro to create a point like button

sorry for the confusion.

I re read your post and realized you want to create the point on surface after surface selection. if this is the case then have the script select the surface and then start the point function, this will come as point on surface by default as a surface is already selected.

CODE --> vba

Sub CATMain()

If CATIA.ActiveDocument.Selection.Count = 1 Then
    If TypeName(CATIA.ActiveDocument.Selection.Item(1).Value) = "Face" Then
        CATIA.StartCommand ("Point")
    End If
End If

End Sub 

Eric N.
indocti discant et ament meminisse periti

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