Methode HeadTarget failed
Methode HeadTarget failed
(OP)
HI,
I would like de write a macro, for catdrawings, to check to wicht Parts the balloons are linked.
I saw the post Link and try the metode "HeadTaget"
Ther my code:
But it don't works : i allways have the message : "methode HeadTarget failed"
Regards
Marc.
I would like de write a macro, for catdrawings, to check to wicht Parts the balloons are linked.
I saw the post Link and try the metode "HeadTaget"
Ther my code:
CODE --> VBA
'**************************************************************
'*** Macro To check witch Part the balloon is pointed ***
'*** ***
'*** VBA ***
'*** ***
'**************************************************************
Sub CATMain()
On Error Resume Next
Set MonDessin = CATIA.ActiveDocument
If (Err.Number <> 0) Then
MsgBox ("Un CATDrawing doit être actif")
Exit Sub
End If
If (InStr(MonDessin.Name, ".CATDrawing")) = 0 Then
MsgBox ("La fenêtre active doit être un CATDrawing")
Exit Sub
End If
Err.Clear
On Error GoTo 0
Dim ElemDispatch As CATBaseDispatch
Dim myBalloon As DrawingText
Dim myleaders As DrawingLeaders
Dim myleader As DrawingLeader
Set selection1 = MonDessin.Selection
'selection1.Search "Name=Numéro de pièce*,all" ' CATIA IN FRENCH
selection1.Search "Name=Balloon*,all" ' CATIA IN ENGLICH
For i = 1 To selection1.Count
Set myBalloon = selection1.Item(i).Value
Set myleaders = myBalloon.Leaders
Set myleader = myleaders.Item(1)
Set ElemDispatch = Nothing
Set ElemDispatch = myleader.HeadTarget
MsgBox myBalloon.Text & "-" & myleader.Name & "-" & ElemDispatch.Name
Next
End Sub But it don't works : i allways have the message : "methode HeadTarget failed"
Regards
Marc.
Regards
Marc





RE: Methode HeadTarget failed
RE: Methode HeadTarget failed
I try with generated geometry and with a line that I create in the drawing : with the line it works (see picture).
Has someone an idea how to retriev the list off the Parts pointed from the balloons?
Regards
Marc
RE: Methode HeadTarget failed
The idea is:
from 2D
Get position of ballonhead (H,V)
Get View plane projection
in 3D:
create new temp part to support temp geometry (I know this will trigger update required for drawingview, open to suggestion)
create a plane similar to plane projection
for each ballonhead, create point on plane (I actually might go with a sketch here to manage H and V)
create infinite line normal to plane passing through point
check distance between line and all bodies from all parts in product
measure intersection point with plane
smallest distance would be of the visible body in drawingview
this part is done
this is still pending
The limitation would be that all parts are projected in drawingview, and view is not made from Scene.
Do you have any idea how to manage those limitation in VBA?
indocti discant et ament meminisse periti
RE: Methode HeadTarget failed
To get the list of parts pointed by balloons you can change the settings in Drafting/Annotation and Dress-up/3D Associativity/Balloon generation =>PartNumber.
I might have gotten the path wrong (I don't know all settings by heart :) ) but you can easily find it.
Let us know if it works for you,
Calin