Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

FTA - Catia V5 - create linear dimension and force direction

Status
Not open for further replies.

user7

Computer
Sep 14, 2022
8
0
0
DE
Hi everyone,

I would like to create a macro for Catia V5 (FTA) which creates ordinate dimensions for all holes. As a start, I would like to create a simple linear dimension between two holes that are not in line (vertically and horizontally). As depicted in the image (red), the linear dimension is, by default, aligned by the elements and is just the direct line between the two holes. I would need the line depicted in blue - which is the ordinate distance in the horizontal direction.


wurfelpmiXX_gqu6xt.png



My current script for creating the red, straight linear dimension between two given cylindrical faces / holes:

Code:
Language="VBSCRIPT"
Sub CATMain(native_view,native_face1,native_face2)

Set partDocument1 = CATIA.ActiveDocument

Set part1 = partDocument1.Part

Set userSurfaces1 = part1.UserSurfaces

Set userSurface1 = userSurfaces1.Generate(native_face1)

Set userSurface2 = userSurfaces1.Generate(native_face2)

Set userSurfComboNode = userSurfaces1.MakeUserSurfaceNode(userSurface1, userSurface2)

Set annotationSet1 = part1.AnnotationSets.Item(1)

Set annotationFactory = annotationSet1.AnnotationFactory

Dim pmi as Annotation;
Set pmi = annotationFactory.CreateSemanticDimension(userSurfComboNode,5,0)  ' 5 = CATTPSOrientedLinearDimension; 0 = CATTPSDistanceDimension

native_view.Annotations.Add(pmi)

End Sub


Does anyone have an idea on how I can create the dimension to be aligned with the horizontal / vertial axis of the view (or by a given vector). Or if/how I can change this alignment after the dimension is created?

wurfelpmiXX-MenueCatia_dhstnc.png


In the editor, this works nicely with a button in the dimension's menue. But I need to do this automatically, in a macro or via the c# api.

I would be very thankful for any comment/hint, as I'm struggling with this issue for several days now and did a lot of try-and-error experiments due to the quite incomplete documentation -.-

Thank you! :)
 
Replies continue below

Recommended for you

Hi again, just in case someone else stumbles over the same issue... I found a quite ugly solution to this problem...
after the dimension (pmi) is created, I select it and just call a "StartCommand" with the text from the context menu - this seems to work.. but I'm quite sure that this is very prune to error and might even collapse if we change the language... -.-
So other suggestions on how to solve this are warmly welcomed :)

Code:
Language="VBScript"
Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim oSel as Selection
Set oSel = partDocument1.selection
oSel.Clear
Dim Filter(0)
Filter(0)="Face"

Dim F_Faces as object
F_Faces = oSel.SelectElement3(Filter, "select faces",False, CATMultiSelectionMode.CATMultiSelTriggWhenUserValidatesSelection, False)

objcount = oSel.count

Dim ref1 As Reference
Set ref1 = oSel.Item(1).Value

Dim ref2 As Reference
Set ref2 = oSel.Item(2).Value

Set userSurfaces1 = part1.UserSurfaces
Set userSurface1 = userSurfaces1.Generate(ref1)
Set userSurface2 = userSurfaces1.Generate(ref2)
Set userSurfComboNode = userSurfaces1.MakeUserSurfaceNode(userSurface1, userSurface2)

Set annotationSet1 = part1.AnnotationSets.Item(1)
Set annotationFactory = annotationSet1.AnnotationFactory
Set pmi = annotationFactory.CreateNonSemanticDimension(userSurfComboNode,5,0)

oSel.Clear
oSel.Add(pmi)

CATIA.StartCommand("Force Horizontal Dimension in View")


msgBox("DONE!!" & oSel.count)
End Sub
 
Status
Not open for further replies.
Back
Top