Autor
|
Thema: VBA Code um eine Plane eines Koordinatensystems anzusprechen (2642 mal gelesen)
|
denniszappi Mitglied Bachelorand
Beiträge: 16 Registriert: 19.06.2015 Windows 7 SP1, 64 bit, CATIA V5 R24
|
erstellt am: 06. Jul. 2015 14:27 <-- editieren / zitieren --> Unities abgeben:
Hi, ich muss für eine "Powercopy" aus einem Makro heraus eine Ebene eines Koordinatensystems ansprechen. Geht dies über eine Art Pfad? Wenn ich den Pfad so programmiere, wie die CATIA Statusleiste ihn anzeigt, funktioniert das Makro nicht. 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: 06. Jul. 2015 14:48 <-- editieren / zitieren --> Unities abgeben: Nur für denniszappi
Hallo Dennis, ohne den genauen Zusammenhang zu kennen: geht's mit ../part/OriginElements/PlaneXY ? Just a thought, Joe
------------------ The problem with the world is that the intelligent people are full of doubts, while the stupid ones are full of confidence. ~Charles Bukowski Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
denniszappi Mitglied Bachelorand
Beiträge: 16 Registriert: 19.06.2015 Windows 7 SP1, 64 bit, CATIA V5 R24
|
erstellt am: 06. Jul. 2015 14:55 <-- editieren / zitieren --> Unities abgeben:
Hey Joe, danke für deine Antwort. Ich habe mehrere Koordinatensysteme in meinem Part, auf dessen Koordinaten jewels ein ein Template per Makro einfügt werden soll. Hierfür muss ich einzelne Ebenen der Koordinatensysteme explitzit ansprechen können. Gruß Dennis 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: 06. Jul. 2015 16:20 <-- editieren / zitieren --> Unities abgeben: Nur für denniszappi
Servus Wenn du auf die Ebenen des Achsensystems zugreifen (als Object oder Reference) willst geht dass über BoundaryReprestantation. ggf wäre es einfacher (ich kenne deine Powercopy nicht) statt den Ebenen einfach das ganze Achsensystem als Input zu nehmen. Gruß Bernd ------------------ Warum einfach, wenn es auch kompliziert geht. 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: 06. Jul. 2015 19:38 <-- editieren / zitieren --> Unities abgeben: Nur für denniszappi
Hi Dennis, (war mal kurz AFK) wenn Du nicht weisst, wie die brep-Ebene heisst, zeichne den Vorgang mit dem Makrorekorder auf. Mit Logik und 'n Bischen knobeln kommt man drauf. Tschau, Joe ------------------ The problem with the world is that the intelligent people are full of doubts, while the stupid ones are full of confidence. ~Charles Bukowski Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
denniszappi Mitglied Bachelorand
Beiträge: 16 Registriert: 19.06.2015 Windows 7 SP1, 64 bit, CATIA V5 R24
|
erstellt am: 08. Jul. 2015 15:47 <-- editieren / zitieren --> Unities abgeben:
Leider gab mir der Makrorecorder keine Aufschlüsse darüber, wie ich die einzelne Ebene der K-Systems ansprechen könnte. Mit meinen geringen Vorkenntnissen kann ich auch mit BoundaryRepresentations nichts anfangen. Habe darüber in der Doku nichts gefunden leider. Habe mir jetzt damit beholfen neue Punkte, Linien und Flächen auf dieselbigen das K-Systems zu legen. Nicht gerade elegant. Kann ich aber in meinem Makro vielleicht irgendwie verwursten. Trotzdem Dankeschön für eure Hilfe 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: 08. Jul. 2015 16:43 <-- editieren / zitieren --> Unities abgeben: Nur für denniszappi
Hallo Dennis, die nachfolgende Routine misst den Winkel zwischen einer Oberflächennormalen und den jeweiligen Ebenen des Koordinatensystems. Der Trick besteht darin, zu erkennen welcehn teil Du mit Deiner eigenen Variablen ersetzen kannst. Im unten stehenden Fall: oParent für das Part, oAxSysCos für das Achsensystem.
Code:
'--------------------------------------------------------------------------------------- ' Procedure : GetTestPointData ' Author : jherzog ' Date : 28.07.2014 ' Time : 17:16 ' Languages : VB6 Pro ' V5-Release: V5R19/21 ' Purpose : create normals thru points on surfaces, collect coordinates and angles into udt-array ' Parms : Parent part ' Ret. Value: - ' ' Syntax : Measurement_Points oADP ' Expects : an opened part holding three sets called 'Measurement_Points', 'WireFrame' and 'Normale' ' '--------------------------------------------------------------------------------------- ' Public Sub GetTestPointData(oParent As Part) Dim i As Long Dim oSel As Selection Dim ohBs As HybridBodies Dim ohBPt As HybridBody 'set with points Dim ohBWF As HybridBody 'set with wireframe Dim ohBN As HybridBody 'set für Normale Dim ohSs As HybridShapes 'set with points Dim ohSSw As HybridShapes 'set with sweep Dim ohSLn As HybridShapes 'set für normale Dim ohSF As Factory Dim ohSurf As HybridShape 'the point is on this (existing) surface Dim ohPtSurf As HybridShape '(existing) point on surface Dim oCoord(2) ' As Double 'array for point coordinates Dim RefPt As Reference 'ref point for line Dim RefSurf As Reference 'ref surf for line Dim X_Axis As Reference 'ref axis of oAxSysCos Dim Y_Axis As Reference Dim Z_Axis As Reference Dim lnNorm As Reference 'ref of ohSLnNorm Dim ohSLnNorm As HybridShapeLineNormal 'Normal line thru current point Dim oCurrAx As AxisSystem 'save the current axis system, set current on exit Dim oAxSysCos As AxisSystem 'axis system for measuring angles Dim SPA_WB As Workbench Dim FirstElem As Measurable 'representing the normal line '------------------------------------------------------------------------------------------ Set oSel = oParent.Parent.Selection 'select from the part's parent Set ohSF = oParent.HybridShapeFactory Set ohBs = oParent.HybridBodies Set ohBPt = ohBs.Item("Measurement_Points") 'Annahme: Set existiert im grundmodell; alle messpunkte sind im set Assignment Points Set ohBWF = ohBs.Item("WireFrame") 'Annahme: alle Bezugsflächen der Punkte sind im set WireFrame Set ohBN = ohBs.Item("Normale") 'Annahme: Set existiert im Grundmodell; alle Oberflächen-Normale kommen hier rein; Set ohSs = ohBPt.HybridShapes 'alle messpunkte Set ohSSw = ohBWF.HybridShapes 'alle elemente aus dem wireframe set Set ohSLn = ohBWF.HybridShapes 'alle normale'what needs to be done first Set oCurrAx = GetCurrAxSys(oParent) 'save value of current axis; restore on exit Set oAxSysCos = CreateNewAxisSp(oParent, "RichtungsCosSystem") 'create axis for measuring angles Set SPA_WB = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench") ReDim PtTest(1 To ohSs.Count) 'redim the point record array 'now get the data For i = 1 To ohSs.Count 'punkte durchlaufen Set ohPtSurf = ohSs.Item(i) Set RefPt = oParent.CreateReferenceFromObject(ohPtSurf) 'ref bilden aus punkt Set ohSurf = ohSSw.Item(ohPtSurf.Surface.DisplayName) 'stützfläche identifizieren Set RefSurf = oParent.CreateReferenceFromObject(ohSurf) 'ref bilden aus der fläche Set ohSLnNorm = ohSF.AddNewLineNormal(RefSurf, RefPt, 0#, 100#, False) 'oberflächennormale erzeugen ohSLnNorm.Name = "Normale_" & ohPtSurf.Name 'normale umbenennen ohBN.AppendHybridShape ohSLnNorm 'dem set Normale zuordnen ohSLnNorm.Compute 'fertigstellen oAxSysCos.OriginPoint = RefPt 'achse in messpunkt verschieben oSel.Clear oSel.Add ohSLnNorm oSel.VisProperties.SetRealColor 255, 0, 255, 1 'magenta (Farbe über RGB definieren) oSel.VisProperties.SetRealLineType 4, 1 'dot-dash (Linienart definieren) oSel.VisProperties.SetRealWidth 1, 1 '0.13 (Liniendicke definieren) oSel.Clear ohPtSurf.GetCoordinates oCoord 'punkt-coordinaten ermitteln Set lnNorm = oParent.CreateReferenceFromObject(ohSLnNorm) 'ref der normalen bilden 'refs der schenkel des neuen achsensystems bilden Set X_Axis = oParent.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(" & oAxSysCos.Name & ";1);None:();Cf11:());Face:(Brp:(" _ & oAxSysCos.Name & ";3);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;" & _ "WithSelectingFeatureSupport;MFBRepVersion_CXR15)", oAxSysCos) Set Y_Axis = oParent.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(" & oAxSysCos.Name & ";2);None:();Cf11:());Face:(Brp:(" _ & oAxSysCos.Name & ";1);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;" & _ "WithSelectingFeatureSupport;MFBRepVersion_CXR15)", oAxSysCos) Set Z_Axis = oParent.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(" & oAxSysCos.Name & ";3);None:();Cf11:());Face:(Brp:(" _ & oAxSysCos.Name & ";2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;" & _ "WithSelectingFeatureSupport;MFBRepVersion_CXR15)", oAxSysCos) Set FirstElem = SPA_WB.GetMeasurable(lnNorm) 'the newly created normal is reference for all angles PtTest(i).PtName = ohPtSurf.Name 'fill in the name PtTest(i).X = oCoord(0) 'the coordinates PtTest(i).Y = oCoord(1) PtTest(i).Z = oCoord(2) PtTest(i).cos_alpha = FirstElem.GetAngleBetween(X_Axis) 'the PtTest(i).cos_beta = FirstElem.GetAngleBetween(Y_Axis) 'angles PtTest(i).cos_gamma = FirstElem.GetAngleBetween(Z_Axis) 'one leg of the axis system at a time Next '------------------------------------------------------------------------------------------------------------------------------------- 'clean up oCurrAx.IsCurrent = True 'reset original axis system to current ' Set oSel = oParent.Parent.Selection 'select from the part's parent oSel.Clear oSel.Add oAxSysCos oSel.Delete 'delete the ref axis oSel.Clear oParent.Update End Sub
Vergleiche den Code mit einem Mitschnitt des Rekorders. Tschau, Joe ------------------ The problem with the world is that the intelligent people are full of doubts, while the stupid ones are full of confidence. ~Charles Bukowski Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
ptit.tom Mitglied CAD-Berater
Beiträge: 114 Registriert: 11.02.2005 win10, CATIA R19 bis R30
|
erstellt am: 14. Jul. 2015 13:46 <-- editieren / zitieren --> Unities abgeben: Nur für denniszappi
Hallo, Ich hatte vor kurz die gleiche Problematik (also BRep eines Achsensystem im Makro ansprechen). Ich habe eine Funktion geschrieben, um belibiege Elemente zu bekommen. Die Funktion liefert eine Refenrenz zurück. XYZ beschreibt, was mal will: O für den Ursprung, X, Y oder Z für die Achsen, XY, YZ oder ZX für die Ebene. Code: Function GetReferenceFromAxisSystem(XYZ As String, oPart As Part, MyAS As AxisSystem) As Reference 'XYZ define which element should be taken 'Get AxisSystem Local Name Dim IntName As String IntName = MyAS.GetItem("ModelElement").InternalName Dim LocalRef As Reference Select Case XYZ Case "O" 'Origin Set LocalRef = oPart.CreateReferenceFromBRepName("FVertex:(Vertex:(Neighbours:(Face:(Brp:(" & IntName & ";2);None:();Cf11:());Face:(Brp:(" & IntName & ";3);None:();Cf11:());Face:(Brp:(" & IntName & ";1);None:();Cf11:()));Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", MyAS) Case "X" 'X-Axis Set LocalRef = oPart.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(" & IntName & ";1);None:();Cf11:());Face:(Brp:(" & IntName & ";3);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", MyAS) Case "Y" 'Y-Axis Set LocalRef = oPart.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(" & IntName & ";2);None:();Cf11:());Face:(Brp:(" & IntName & ";1);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", MyAS) Case "Z" 'Z-Axis Set LocalRef = oPart.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(" & IntName & ";3);None:();Cf11:());Face:(Brp:(" & IntName & ";2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", MyAS) Case "XY" 'XY-Plane Set LocalRef = oPart.CreateReferenceFromBRepName("RSur:(Face:(Brp:(" & IntName & ";1);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", MyAS) Case "YZ" 'YZ-Plane Set LocalRef = oPart.CreateReferenceFromBRepName("RSur:(Face:(Brp:(" & IntName & ";2);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", MyAS) Case "ZX" 'ZX-Plane Set LocalRef = oPart.CreateReferenceFromBRepName("RSur:(Face:(Brp:(" & IntName & ";3);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", MyAS) Case Else LocalRef = Nothing End Select Set GetReferenceFromAxisSystem = LocalRef End Function
[Diese Nachricht wurde von ptit.tom am 14. Jul. 2015 editiert.] Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
| Anzeige.:
Anzeige: (Infos zum Werbeplatz >>)
|