Autor
|
Thema: Problem bei Selection.add (844 / mal gelesen)
|
RAA Mitglied CAD/PDM-Supporter
Beiträge: 57 Registriert: 05.08.2009 HP Z420 Intel Xeon 3,6GHz 32GB Windows 7 Enterprise V5R19+R22+R24+R26 VB.net 2010
|
erstellt am: 18. Apr. 2017 14:51 <-- editieren / zitieren --> Unities abgeben:
Hallo, ich versuche gerade im Background einer Drawing die Linienstärke der gerade erzeugten Linien zu ändern, aber ich schaffe es nicht. Dim selection As INFITF.Selection selection = CATIA.ActiveDocument.Selection Dim Line2D As Factory2D Dim visProperties As INFITF.VisPropertySet visProperties = selection.VisProperties selection.Clear() Line2D = BackView.Factory2D.CreateLine(Heftrand, Offset, SF_Offs, Offset) selection.Add(Line2D) .... MsgBox(selection.Count.ToString) selection.VisProperties.SetRealWidth(4, 1) Oben ein Auszug aus meinem Konstrukt. Die Linien werden erzeugt. Ich möchte alle erzeugten Linien in einer Selection zusammenfassen, aber Selection.Count sagt über die messagebox 0 Elemente. Was läuft hier schief? Gruß Rainer Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
joehz Moderator Freiberuflicher Konstrukteur
Beiträge: 1057 Registriert: 25.11.2006 Win7 Pro 64 + Ubuntu + Irix6.5.20 Dell Precision M6600 i7-2960XM 2.7GHz 16GB NVidia Quadro M5010 Catia V5R19 VB6Pro.SP6/VBA 6.5.1053
|
erstellt am: 18. Apr. 2017 15:58 <-- editieren / zitieren --> Unities abgeben: Nur für RAA
Hi RAA, nachfolgend eine ähnliche Routine. Indem ich die Elemente umbenenne, lassen sie sich gezielt ansprechen. Code:
'--------------------------------------------------------------------------------------- ' Procedure : DrawRect ' Author : jherzog ' Date : 07.10.2014 ' Time : 22:06 ' Languages : VB6 Pro ' V5-Release: V5R19/21 ' Purpose : Draw system parallel rubber band box between to points ' Parms : strView: Name of view to draw to ' : dPStart():Start point variant array (0) = x, (1) = y; ' : dPEnd(): End point ' : iLnType(optional): Line type, as specified acc. to catia standards ' : iLnThck(optional): Line thickness ' : iLnColx(optional): RGB-color values ' Ret. Value: - ' ' Syntax : DrawRect odrVw.Name, ptStart, ptEnd, 6, 1, 128, 0, 255 ' : (Dot-Dashed, 0.13, light purple) ' Prereqs : - ' Remarks : Only for system parallel views(0°, 90°, 180°, 270°) '--------------------------------------------------------------------------------------- ' Sub DrawRect(strView As String, dPStart(), dPEnd(), _ Optional iLnType As Integer, _ Optional iLnThck As Integer, _ Optional iLnColR As Integer = -1, _ Optional iLnColG As Integer = -1, _ Optional iLnColB As Integer = -1) Dim odrVw As DrawingView Dim oF2D As Factory2D Dim lnRect(3) ' As Line2D Dim oSel As Selection Dim visProps As VisPropertySet Set odrVw = oAD.Sheets.ActiveSheet.Views.Item(strView) odrVw.Activate Set oF2D = odrVw.Factory2D Set oSel = CATIA.ActiveDocument.Selection Set lnRect(0) = oF2D.CreateLine(dPStart(0), dPStart(1), dPEnd(0), dPStart(1)) Set lnRect(1) = oF2D.CreateLine(dPEnd(0), dPStart(1), dPEnd(0), dPEnd(1)) Set lnRect(2) = oF2D.CreateLine(dPEnd(0), dPEnd(1), dPStart(0), dPEnd(1)) Set lnRect(3) = oF2D.CreateLine(dPStart(0), dPEnd(1), dPStart(0), dPStart(1)) lnRect(0).Name = "TEMPRECT_" & lnRect(0).Name lnRect(1).Name = "TEMPRECT_" & lnRect(1).Name lnRect(2).Name = "TEMPRECT_" & lnRect(2).Name lnRect(3).Name = "TEMPRECT_" & lnRect(3).Name Set visProps = oSel.VisProperties oSel.Search "Name=TEMPRECT_*,all" If oSel.Count2 > 0 Then If Not IsMissing(iLnColR) And Not IsMissing(iLnColG) And Not IsMissing(iLnColB) Then visProps.SetRealColor iLnColR, iLnColG, iLnColB, 0 End If If Not IsMissing(iLnType) Then visProps.SetRealLineType iLnType, 0 If Not IsMissing(iLnThck) Then visProps.SetRealWidth iLnThck, 0 oSel.Clear End If End Sub
Hope it helps, Joe ------------------ Inoffizielle Catia Hilfeseite Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
bgrittmann Moderator Konstrukteur
Beiträge: 11780 Registriert: 30.11.2006 CATIA V5R19
|
erstellt am: 19. Apr. 2017 09:15 <-- editieren / zitieren --> Unities abgeben: Nur für RAA
Servus Rainer Als CATScript geht das hinzufügen der Linie zur Selektion. Verschluckt sich dein Code daran, dass die Elemente genauso heißen wie ihr Objekttyp oder die Linie als Line2D dimensioniert sein müsste? Statt den Umweg über die Suche, wie von Joe beschrieben, könntest auch das letzte Element der GeometricElements selektieren. Gruß Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
RAA Mitglied CAD/PDM-Supporter
Beiträge: 57 Registriert: 05.08.2009 HP Z420 Intel Xeon 3,6GHz 32GB Windows 7 Enterprise V5R19+R22+R24+R26 VB.net 2010
|
erstellt am: 19. Apr. 2017 09:32 <-- editieren / zitieren --> Unities abgeben:
Hallo, danke euch Beiden für die Hinweise. Des Rätsels Lösung ist die Typisierung der Linie. Ich habe die Variable von Dim Line2D As Factory2D auf Dim Linie As Line2D geändert - und schon geht´s. Gruß Rainer Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
| Anzeige.:
Anzeige: (Infos zum Werbeplatz >>)
|