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!

Macro to create a point like button

Status
Not open for further replies.

RSilva

Mechanical
Jun 23, 2017
35
PT
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:
Language="VBSCRIPT"

Sub CATMain()

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

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

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

Set reference1 = part1.CreateReferenceFromObject(axisSystem1)
hybridShapeDirection1.RefAxisSystem = reference1
[COLOR=#EF2929]
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item("bp50")

Set shapes1 = body1.Shapes
Set solid1 = shapes1.Item("Solid.106")
[/color]
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
 
Replies continue below

Recommended for you

read the online doc about Selection.IndicateOrSelectElement3D

Eric N.
indocti discant et ament meminisse periti
 
There are a problem, as i can see, i can only use Selection.IndicateOrSelectElement3D on planar Geometries, that limit alot
 
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
 
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?


 
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
 
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
 
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:
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top