Autor
|
Thema: Produkt-Ansicht an Zeichnung generation (1411 mal gelesen)
|
Sylas Mitglied
Beiträge: 322 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 23. Mrz. 2015 13:07 <-- editieren / zitieren --> Unities abgeben:
Hallo Leute Ich habe ein Kode im Hilfe-Datei gefunden, welches Frontview aus Part/Pad an der Zeichnung generiert. Ich habe der Kode ein bischen ueberarbeitet fuer mein Fall: Code: If UserForm1.CKB_Pierwszy_arkusz.Value = True Then CATIA.ActiveDocument.Sheets.Item("BLATT001").Activate CATIA.ActiveDocument.Sheets.Item("BLATT001").Views.Item(1).Activate Dim DrawingSelection, DrawingSheets, DrawingSheet, DrawingViews, DrawingFrontView: ReDim DrawingSelectionAtBeginning(1) Dim Status, InputObjectType(0), Plane, Drawing, DrawingViewGenerativeBehavior, V1(2), V2(2), PartDocument Set Drawing = CATIA.ActiveDocument: Set DrawingSelection = Drawing.Selection: Set DrawingSheets = Drawing.Sheets Set DrawingSheet = DrawingSheets.ActiveSheet 'We save the current selection content ReDim DrawingSelectionAtBeginning(DrawingSelection.Count2) For SelectionObjectIndex = 0 To DrawingSelection.Count2 - 1 Set DrawingSelectionAtBeginning(SelectionObjectIndex) = DrawingSelection.Item2(1).Value Next SelectionAtBeginningLength = DrawingSelection.Count2 'Feature creation 'InputObjectType(0) = "Plane" InputObjectType(0) = "BiDimInfinite" Status = DrawingSelection.SelectElement4(InputObjectType, "Select a 2-D topological entity in a 3-D geometry", _ "Select a 2-D topological entity", False, PartDocument) If ((Status = "Cancel") Or (Status = "Undo") Or (Status = "Redo")) Then ' We restore the selection to its initial content PartDocument.Selection.Clear For SelectionObjectIndex = 0 To SelectionAtBeginningLength - 1 DrawingSelection.Add DrawingSelectionAtBeginning(SelectionObjectIndex) Next Exit Sub Else Set BiDimFeature = PartDocument.Selection.Item2(1).Value BiDimFeatureType = TypeName(BiDimFeature) 'If (BiDimFeatureType = "Plane") Then If ((BiDimFeatureType = "Plane") Or (BiDimFeatureType = "PlanarFace")) Then BiDimFeature.GetFirstAxis V1 BiDimFeature.GetSecondAxis V2 Else Exit Sub End If ' We create a view called "Front View" in the current sheet, using Plane as projection plane, and whose origin ' coordinates are 300,150 Set DrawingFrontView = DrawingSheet.Views.Add("Front View") Set DrawingViewGenerativeBehavior = DrawingFrontView.GenerativeBehavior DrawingViewGenerativeBehavior.Document = PartDocument.Product DrawingViewGenerativeBehavior.DefineFrontView V1(0), V1(1), V1(2), V2(0), V2(1), V2(2) DrawingFrontView.X = 300 DrawingFrontView.Y = 150 DrawingViewGenerativeBehavior.Update ' We clear the PartDocument Selection object PartDocument.Selection.Clear End If
Es ist ein Auschnitt aus grossere Projekt. Wenn user ein Plane einklickst, makro soll ein Frontview aus der Produkt generieren. Das Problem ist, wenn ich Planarface an der Part zuerst klicke, Makro lauft Gut. Ich muss aber immer den Ansicht im Auto-Null generieren (XY, YZ oder XZ Plane aus Global-AutoNull Achsenkreuz). Wenn ich als Input eine Ebene aus AutoNull zeige, das Kode generiert mir kein Ansicht. Weiss jemand warum? sorry fuer mein schlecht Deutsch. Lukas 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: 23. Mrz. 2015 20:16 <-- editieren / zitieren --> Unities abgeben: Nur für Sylas
Servus Lukas Hast du ein Bild von der Baugruppe/Ebene wenn das Makro nicht funktioniert? Wenn das Makro fehlt schlägt: - gibt es eine Fehlermeldung? - wird ggf der entsprechende Code übersprungen (schrittweise ausführen oder MsgBoxen für den Ablauf hinzufügen) - hast du im Code ein "on error resume next"? - ist die Ansicht danach leer? Gruß Bernd PS: Ist es für dich einfacher, die Problematik in Englisch weiter zu diskutieren? PS2: Ich hab mal etwas rum getestet: ggf bricht das Makro immer bei Abfrage nach "BiDimFeatureType" ab. Ist das der korrekte Filter für dich? ------------------ Warum einfach, wenn es auch kompliziert geht. Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Sylas Mitglied
Beiträge: 322 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 24. Mrz. 2015 14:40 <-- editieren / zitieren --> Unities abgeben:
Hello Bernd I'm sorry to inform you, that I've completely change the approach to the problem . Now the user can choose which Car-zero plane should be used to generate the Frontview: Code: Dim productDocument1 As ProductDocument Set productDocument1 = CATIA.ActiveDocument Dim selection1 As Selection Set selection1 = productDocument1.Selection selection1.Search "Name=*adapter,all" Dim adapter As Part Set adapter = selection1.Item(1).Value Dim view_plane As Plane Dim V1(2) Dim V2(2) Dim pl, pl_top, pl_left As String If Plaszczyzna.OB_XY.Value = True Then Set view_plane = adapter.OriginElements.PlaneXY pl = "XY" ElseIf Plaszczyzna.OB_XZ.Value = True Then Set view_plane = adapter.OriginElements.PlaneZX pl = "ZX" Else Set view_plane = adapter.OriginElements.PlaneYZ pl = "YZ" End If Set BiDimFeature = view_plane BiDimFeature.GetFirstAxis V1 BiDimFeature.GetSecondAxis V2 CATIA.Documents.Item(DrawingName).Activate Dim DrawingFrontView As DrawingView Set DrawingFrontView = CATIA.ActiveDocument.Sheets.Item("BLATT001").Views.Add("Front View") Set DrawingFrontViewGenerativeBehavior = DrawingFrontView.GenerativeBehavior Dim DrawingFrontViewGenerativeLinks As DrawingViewGenerativeLinks Set DrawingFrontViewGenerativeLinks = DrawingFrontView.GenerativeLinks DrawingFrontViewGenerativeBehavior.Document = CATIA.Documents.Item(ProductName).Product DrawingFrontViewGenerativeBehavior.DefineFrontView V1(0), V1(1), V1(2), V2(0), V2(1), V2(2) Dim Sheetheight As Double Dim Sheetwidth As Double Dim ShtSize As DrawingSheet Set ShtSize = CATIA.ActiveDocument.Sheets.Item("BLATT001") Sheetheight = ShtSize.GetPaperHeight Sheetwidth = ShtSize.GetPaperWidth DrawingFrontViewGenerativeBehavior.Update ukryj DrawingFrontView DrawingFrontView.Activate DrawingFrontView.[Scale] = 0.5 Dim Frontviewsize(3) 'As Double Dim DrwFrontSize Set DrwFrontSize = DrawingFrontView DrwFrontSize.Size Frontviewsize DrawingFrontView.X = (Frontviewsize(1) - Frontviewsize(0)) / 2 + 75 DrawingFrontView.Y = Sheetheight - ((Frontviewsize(3) - Frontviewsize(2)) / 2 + 45) DrwFrontSize.Size Frontviewsize 'DrawingFrontView.X = 200 'DrawingFrontView.Y = 650 Siatka DrawingFrontView, 50, (1 / DrawingFrontView.[Scale]), pl Dim offsetview2 As Double offsetview2 = 100 DrawingFrontView.Activate
Once again - sorry. If it's possible - could you help me to generate Topview and Leftview from the generated Front view? My current problem is, that CATIA generates both views for me, but their relative position is adjustable along veird (diagonal?) axis instead horizontal axis (leftview) or vertical axis(topview). Sample code below:
Code: Dim DrawingTopView As DrawingView Set DrawingTopView = CATIA.ActiveDocument.Sheets.Item("BLATT001").Views.Add("AutomaticNaming")Dim DrawingTopViewGenerativeBehavior As DrawingViewGenerativeBehavior Set DrawingTopViewGenerativeBehavior = DrawingTopView.GenerativeBehavior DrawingTopViewGenerativeBehavior.DefineProjectionView DrawingFrontViewGenerativeBehavior, catTopView Dim DrawingTopViewGenerativeLinks As DrawingViewGenerativeLinks Set DrawingTopViewGenerativeLinks = DrawingTopView.GenerativeLinks Set DrawingFrontViewGenerativeLinks = DrawingFrontView.GenerativeLinks DrawingFrontViewGenerativeLinks.CopyLinksTo DrawingTopViewGenerativeLinks DrawingTopView.[Scale] = 0.5 Set DrawingTopViewGenerativeBehavior = DrawingTopView.GenerativeBehavior DrawingTopViewGenerativeBehavior.Update DrawingTopView.ReferenceView = DrawingFrontView DrawingTopView.AlignedWithReferenceView Dim Topviewsize(3) 'As Double Dim DrwTopSize Set DrwTopSize = DrawingTopView DrwTopSize.Size Topviewsize DrawingTopView.X = DrawingFrontView.X
DrawingTopView.Y = Frontviewsize(2) - ((Topviewsize(3) - Topviewsize(2)) / 2) - offsetview2 ukryj DrawingTopView If pl = "XY" Then pl_top = "XZ" ElseIf pl = "ZX" Then pl_top = "ZY" Else pl_top = "YX" End If Siatka DrawingTopView, 50, (1 / DrawingTopView.[Scale]), pl_top
Dim DrawingLeftView As DrawingView Set DrawingLeftView = CATIA.ActiveDocument.Sheets.Item("BLATT001").Views.Add("AutomaticNaming") Dim drawingViewGenerativeBehavior3 As DrawingViewGenerativeBehavior Set drawingViewGenerativeBehavior3 = DrawingLeftView.GenerativeBehavior drawingViewGenerativeBehavior3.DefineProjectionView DrawingFrontViewGenerativeBehavior, catLeftView Dim drawingViewGenerativeLinks3 As DrawingViewGenerativeLinks Set drawingViewGenerativeLinks3 = DrawingLeftView.GenerativeLinks DrawingFrontViewGenerativeLinks.CopyLinksTo drawingViewGenerativeLinks3 DrawingLeftView.[Scale] = 0.5 Set drawingViewGenerativeBehavior3 = DrawingLeftView.GenerativeBehavior drawingViewGenerativeBehavior3.Update DrawingLeftView.ReferenceView = DrawingFrontView DrawingLeftView.AlignedWithReferenceView Dim Leftviewsize(3) 'As Double Dim DrwLeftSize Set DrwLeftSize = DrawingLeftView DrwLeftSize.Size Leftviewsize DrawingLeftView.X = Frontviewsize(1) + ((Leftviewsize(1) - Leftviewsize(0)) / 2) + offsetview2 DrawingLeftView.Y = DrawingFrontView.Y ukryj DrawingLeftView If pl = "XY" Then pl_left = "ZY" ElseIf pl = "ZX" Then pl_left = "YX" Else pl_left = "XZ" End If Siatka DrawingLeftView, 50, (1 / DrawingLeftView.[Scale]), pl_left
Both Functions recalled: Code:
'========================================================================== '--------------- SIATKA ------------------ '========================================================================== Sub Siatka(ByRef docuview As DrawingView, ByVal WIDTH As Integer, ByVal skala As Integer, ByVal pl As String)Dim Hlabel As String Dim Vlabel As String Hlabel = Left(pl, 1) Vlabel = Right(pl, 1) docuview.Activate Dim ddocuview Set ddocuview = docuview Dim xAxisOrig, yAxisOrig As Integer Dim xAxis, yAxis As Integer xAxisOrig = Round(docuview.xAxisData) yAxisOrig = Round(docuview.yAxisData) xAxis = Round(docuview.X) yAxis = Round(docuview.Y) '======================================================= Dim xmin, xmax, ymin, ymax As Integer Dim xminR, xmaxR, yminR, ymaxR As Double Dim xminRF, xmaxRF, yminRF, ymaxRF As Double 'size of drawingView Dim sizeView(3) ddocuview.Size sizeView xmin = sizeView(0) xmax = sizeView(1) ymin = sizeView(2) ymax = sizeView(3) xminR = (Round(xmin) - xAxisOrig) * skala xmaxR = (Round(xmax) - xAxisOrig) * skala yminR = (Round(ymin) - yAxisOrig) * skala ymaxR = (Round(ymax) - yAxisOrig) * skala Do While (xminR Mod WIDTH) <> 0 xminR = xminR - 1 Loop Do While (yminR Mod WIDTH) <> 0 yminR = yminR - 1 Loop Do While (xmaxR Mod WIDTH) <> 0 xmaxR = xmaxR + 1 Loop Do While (ymaxR Mod WIDTH) <> 0 ymaxR = ymaxR + 1 Loop '============================================== xminRF = xminR yminRF = yminR xmaxRF = xmaxR ymaxRF = ymaxR Dim oLine As Line2D Dim oText As DrawingText Do While xminR <= xmaxR Set oLine = docuview.Factory2D.CreateLine(xminR, yminR - (WIDTH / 2), xminR, ymaxR + (WIDTH / 2)) Set oText = docuview.Texts.Add("", xminR - 8, ymaxR + (WIDTH / 2) + 5) oText.TextProperties.AnchorPoint = catMiddleLeft oText.Text = CStr(xminR) + Hlabel oText.Angle = -90 xminR = xminR + WIDTH Loop
'============================================== xminR = xminRF yminR = yminRF xmaxR = xmaxRF ymaxR = ymaxRF Do While yminR <= ymaxR Set oLine = docuview.Factory2D.CreateLine(xminR - (WIDTH / 2), yminR, xmaxR + (WIDTH / 2), yminR) Set oText = docuview.Texts.Add("", xminR - (WIDTH / 2) + 10, yminR + 8) oText.TextProperties.AnchorPoint = catMiddleRight oText.Text = CStr(yminR) + Vlabel yminR = yminR + WIDTH Loop
Dim Namevispropline As VisPropertySet Dim Selline As Selection Dim Selview As Selection Set Selline = CATIA.ActiveDocument.Selection For L = 2 To docuview.GeometricElements.Count Selline.Add docuview.GeometricElements.Item(L) Next Set Namevisprop = Selline.VisProperties Namevisprop.SetRealWidth 1, 1 Selline.Clear End Sub
Code: Sub ukryj(ByRef DrawingFrontView As DrawingView) Dim Namevisprop As VisPropertySet Dim Selname As Selection Set Selname = CATIA.ActiveDocument.Selection Selname.Add DrawingFrontView.Texts.Item(1) Set Namevisprop = Selname.VisProperties Namevisprop.SetShow 1 Selname.Clear End Sub
If something from the code is missing - give me a feedback and I'll post it. MfG Lukas 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: 24. Mrz. 2015 22:22 <-- editieren / zitieren --> Unities abgeben: Nur für Sylas
Hi Lukas I've only checked the code roughly. I'm wondering how you calculate the position of the views. Code: DrawingTopView.Y = Frontviewsize(2) - ((Topviewsize(3) - Topviewsize(2)) / 2) - offsetview2
In this line you use x and y coordinates for the calculation. Do you need Frontviewsize(3) and Frontviewsize(4) in this line? I guess, before the update of the generativeBehavior of the new view, the views have to be position in the correct order (for Topview x coordinates). Code: ... Dim DrawingTopViewGenerativeBehavior As DrawingViewGenerativeBehavior Set DrawingTopViewGenerativeBehavior = DrawingTopView.GenerativeBehaviorDrawingTopViewGenerativeBehavior.DefineProjectionView DrawingFrontViewGenerativeBehavior, catTopView Dim DrawingTopViewGenerativeLinks As DrawingViewGenerativeLinks Set DrawingTopViewGenerativeLinks = DrawingTopView.GenerativeLinks Set DrawingFrontViewGenerativeLinks = DrawingFrontView.GenerativeLinks DrawingFrontViewGenerativeLinks.CopyLinksTo DrawingTopViewGenerativeLinks DrawingTopView.X = DrawingFrontView.X DrawingTopView.[Scale] = DrawingFrontView.[Scale] 'a suggestion Set DrawingTopViewGenerativeBehavior = DrawingTopView.GenerativeBehavior DrawingTopViewGenerativeBehavior.Update DrawingTopView.ReferenceView = DrawingFrontView DrawingTopView.AlignedWithReferenceView ...
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: 322 Registriert: 19.11.2012 Dell Precision T3500 Intel Xeon W3550 @ 3,07 GHz 12 GB RAM CATIA V5 R28
|
erstellt am: 25. Mrz. 2015 11:47 <-- editieren / zitieren --> Unities abgeben:
Zitat: Original erstellt von bgrittmann: Hi Lukas I've only checked the code roughly. I'm wondering how you calculate the position of the views.Code: DrawingTopView.Y = Frontviewsize(2) - ((Topviewsize(3) - Topviewsize(2)) / 2) - offsetview2
In this line you use x and y coordinates for the calculation. Do you need Frontviewsize(3) and Frontviewsize(4) in this line?
Drawingtopview.Y is actually the relative position of the top view regarding drawingfrontview. So the X-coordinate stays the same, but Y coordinate must be: min Y position of the front view (Frontviewsize(2))-offset between front and top view (offsetview2)-half of the topview "height",which is (Topviewsize(3) - Topviewsize(2)) / 2 Both viewsize matrixes consists of 4 items: Xmin,Xmax,Ymin,Ymax. I hope that clear things to you. Code:
Dim Frontviewsize(3) 'As Double Dim DrwFrontSize Set DrwFrontSize = DrawingFrontView DrwFrontSize.Size Frontviewsize
I guess, before the update of the generativeBehavior of the new view, the views have to be position in the correct order (for Topview x coordinates).
Code: ... Dim DrawingTopViewGenerativeBehavior As DrawingViewGenerativeBehavior Set DrawingTopViewGenerativeBehavior = DrawingTopView.GenerativeBehaviorDrawingTopViewGenerativeBehavior.DefineProjectionView DrawingFrontViewGenerativeBehavior, catTopView Dim DrawingTopViewGenerativeLinks As DrawingViewGenerativeLinks Set DrawingTopViewGenerativeLinks = DrawingTopView.GenerativeLinks Set DrawingFrontViewGenerativeLinks = DrawingFrontView.GenerativeLinks DrawingFrontViewGenerativeLinks.CopyLinksTo DrawingTopViewGenerativeLinks DrawingTopView.X = DrawingFrontView.X DrawingTopView.[Scale] = DrawingFrontView.[Scale] 'a suggestion Set DrawingTopViewGenerativeBehavior = DrawingTopView.GenerativeBehavior DrawingTopViewGenerativeBehavior.Update DrawingTopView.ReferenceView = DrawingFrontView DrawingTopView.AlignedWithReferenceView ...
Regards, Bernd [/i][/QUOTE] Problem of the relative positions of the view is already solved - I've used recorded makro as a template for my case and now everything works
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
| Anzeige.:
Anzeige: (Infos zum Werbeplatz >>)
|