| |  | CATIA V5 Grundkurs | Einsteiger - 5 Std. 15 Min 48 | | |  | KISTERS 3DViewStation: Schutz sensibler 3D CAD Daten, egal von wo Sie arbeiten, eine Pressemitteilung
|
Autor
|
Thema: FTA DrawingText repositioning (530 mal gelesen)
|
Sylas Mitglied
 
 Beiträge: 349 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 17. Aug. 2023 09:15 <-- editieren / zitieren --> Unities abgeben:         
Hello Community! I wrote a little macro to postion FTA text B in related position to FTA text A. It seems working, but somehow, it doesn't repeat it more then twice. Can someone tell me where have I made something wrong? Basically what it does, it measures displacement between two positions and gives user the posibility (through form) to eiteh copy exact X/Y coordinate, or to add aditional offset. After clicking on X or Y it should ask user if she/he wants to repeat the process or end. And this is the point where it stops working as it should  Unfortunately, because of the privacy policy of my company - I can't upload a file - sorry Please help me find the problem  Thanks in advacne Lucas Module code Code:
Global oText_source As DrawingText Global oText_target As DrawingText Global X_Pos_S As Double Global Y_Pos_S As Double Global X_Pos_T As Double Global Y_Pos_T As Double Global coord As String Sub CATMain()'Dim oText_source As DrawingText 'Dim oText_target As DrawingText Dim sName As String Dim sNewName As String Dim odSel As Selection Dim oSel Dim InputObjectType(0) As Variant Set odSel = CATIA.ActiveDocument.Selection odSel.Clear Set oSel = odSel InputObjectType(0) = "AnyObject" Result = oSel.SelectElement2(InputObjectType, "Select source", True) '.SelectElement3(InputObjectType, "Wybierz źródło", True, CATMultiSelTriggWhenUserValidatesSelection, True) Set oAnn_source = oSel.Item(1).Value Set oText_source = oAnn_source.Text.Get2dAnnot X_Pos_S = oText_source.X Y_Pos_S = oText_source.Y odSel.Clear Result = oSel.SelectElement2(InputObjectType, "Select target", True) 'SelectElement3(InputObjectType, "Wybierz cel", True, CATMultiSelTriggWhenUserValidatesSelection, True) Set oAnn_target = oSel.Item(1).Value Set oText_target = oAnn_target.Text.Get2dAnnot X_Pos_T = oText_target.X Y_Pos_T = oText_target.Y MsgBox ("Displacement in X: " & Round(Abs(X_Pos_T - X_Pos_S), 0) & vbNewLine & "Displacement in Y: " & Round(Abs(Y_Pos_T - Y_Pos_S), 0))
Pos_form.Show If coord = "X" Then GoTo copying_X_postion Else GoTo copying_Y_postion End If
copying_X_postion: oText_target.X = CDbl(X_Pos_S) + CDbl(Pos_form.X_Disp) oAnn_target.ModifyVisu GoTo replay copying_Y_postion: oText_target.Y = CDbl(Y_Pos_S) + CDbl(Pos_form.Y_Disp) oAnn_target.ModifyVisu GoTo replay replay: test = MsgBox("Chciałbyś spróbować jeszcze raz?", vbYesNo, "Korekta") If test = vbYes Then Pos_form.Show Else GoTo update End If update: oAnn_target.ModifyVisu MsgBox ("Gotowe!") End Sub
Form codeCode: Private Sub UserForm_Initialize() Me.X_Source = Round(oText_source.X, 0) Me.Y_Source = Round(oText_source.Y, 0) End SubPrivate Sub X_Pos_Click() Pos_form.Hide coord = "X" End Sub Private Sub Y_Pos_Click() Pos_form.Hide coord = "Y" End Sub
EDIT: Just noticed, I've double-posted @admin - please remove the other post of FTA NOA displacement, or merge them together  [Diese Nachricht wurde von Sylas am 17. Aug. 2023 editiert.] Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
       
 Beiträge: 12054 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 17. Aug. 2023 10:57 <-- editieren / zitieren --> Unities abgeben:          Nur für Sylas
Hi Lucas What should be repeated? Where does it stops? be aware: after test = vbYes Pos_form.Show the script jumps to update: regards, Bernd
------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sylas Mitglied
 
 Beiträge: 349 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 17. Aug. 2023 12:17 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von bgrittmann: Hi LucasWhat should be repeated? Where does it stops? be aware: after [i]test = vbYes Pos_form.Show the script jumps to update: regards, Bernd [/i]
Hi Bernd After user decides to "copy" the X (or Y) coordinate, the mesage (result) shuold pop up asking user if he/she wants to repeat the process (again for X or for Y coordinate). I'm wondering, why does it not work that way... Best regards Lucas
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
       
 Beiträge: 12054 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 17. Aug. 2023 12:48 <-- editieren / zitieren --> Unities abgeben:          Nur für Sylas
Hi I suggest to set a breaking point and run your code step wise. Your Userform does not call your code in the CATMain again Regards, Bernd PS: GoTo is not used very often in vba, because the code is hard to read/trace ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
| Anzeige.:
Anzeige: (Infos zum Werbeplatz >>)
 |