Ich importiere alle Teile einer Baugruppe in eine TGA, flach
Ich ändere den Maßstab der Blätter von Hand und möchte, dass alle Ansichten den Maßstab des aktuellen Blattes annehmen (das Optionsfeld ist aktiviert: "Den Maßstab des Blattes verwenden"), so dass, wenn ich den Maßstab des Blattes ändere, alle Ansichten den Maßstab ändern
Haben Sie eine Vorstellung von Makros, die alle Registerkarten eines MEP verarbeiten, um alle Ansichten der Registerkarte zu skalieren?
Ich finde es seltsam, dafür ein Makro zu durchlaufen... Aber hier ist ein Beispiel, an dem Sie arbeiten können:
'This example shows how to set the scale of a selected drawing view.
'---------------------------------------------
' Preconditions:
' 1. Open public_documents\introsw\bolt-assembly.slddrw.
' 2. Select a drawing view.
' 3. Open the Immediate window.
'
' Postconditions:
' 1. Increases the selected drawing view's scale.
' 2. Examine the drawing and Immediate window.
'
' NOTE: Because the drawing is used elsewhere, do not
' save changes.
'---------------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim vScaleRatio As Variant
Dim bRet As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSelMgr = swModel.SelectionManager
Set swView = swSelMgr.GetSelectedObject6(1, -1)
vScaleRatio = swView.ScaleRatio
Debug.Print "File = " & swModel.GetPathName
Debug.Print " View = " & swView.Name
Debug.Print " Use sheet scale = " & CBool(swView.UseSheetScale)
Debug.Print " Original scale ratio = " & vScaleRatio(0) & ":" & vScaleRatio(1)
Debug.Print " Original decimal scale value = " & swView.ScaleDecimal
' Increase scale values
' Changing scale sets IView::UseSheetScale to false
vScaleRatio = swView.ScaleRatio
swView.ScaleDecimal = swView.ScaleDecimal * 2#
vScaleRatio = swView.ScaleRatio
Debug.Print ""
Debug.Print " Use sheet scale = " & CBool(swView.UseSheetScale)
Debug.Print " New scale ratio = " & vScaleRatio(0) & ":" & vScaleRatio(1)
Debug.Print " New decimal scale value = " & swView.ScaleDecimal
' Rebuild to see the scaled drawing view
bRet = swModel.EditRebuild3: Debug.Assert bRet
End Sub
Danke für die Antwort, aber ich weiß nicht, wie ich alle Ansichten in einer Schleife schleifen und die Registerskalierung mit der Optionsfeldoption "Blattskalierung verwenden" anwenden soll
Dim swApp As Object
Dim Part As DrawingDoc
Dim currentSheet As Sheet
Dim boolstatus As Boolean
Dim SwModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim vScaleRatio As Variant
Sub Echelle_Feuille_Vues()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
'Feuille
Set currentSheet = Part.GetCurrentSheet
vScaleRatio = currentSheet.GetProperties
Debug.Print ("Échelle Feuille = " & vScaleRatio(2) & " : " & vScaleRatio(3))
a = vScaleRatio(2)
b = vScaleRatio(3)
'Vue
Set swDraw = SwModel
Set SwModel = swApp.ActiveDoc
Set swSelMgr = SwModel.SelectionManager
Set swView = swSelMgr.GetSelectedObject5(1)
vScaleRatio = swView.ScaleRatio
Debug.Print ("Échelle vue = " & vScaleRatio(0) & " : " & vScaleRatio(1))
swView.ScaleDecimal = a / b
boolstatus = SwModel.EditRebuild
End Sub
Ich habe ein Stück Code geschrieben, aber es ist nicht zufriedenstellend
Ich habe nicht gefunden, wie ich alle Ansichten eines Blattes (Tab) in einer Schleife abspielen und das Optionsfeld aktivieren kann
Im Folgenden finden Sie einen Beispielcode zum Schleifen aller Ansichten in einem Tabellenblatt:
'This example shows how to get the display state for each drawing view.
'------------------------------------------------------
' Preconditions:
' 1. Open a drawing.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Traverses the drawing views on the current sheet and
' gets each drawing view's display state.
' 2. Examine the Immediate window.
'
' NOTE: Because the drawing is used elsewhere, do not
' save changes.
'------------------------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim swView As SldWorks.View
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
Set swView = swDraw.GetFirstView
Debug.Print "File = " & swModel.GetPathName
Debug.Print " " & swSheet.GetName
While Not swView Is Nothing
Debug.Print " " & swView.GetName2 & " [" & swView.DisplayState & "]"
Set swView = swView.GetNextView
Wend
End Sub
Hier ist das Makro, das sich mit einer Registerkarte/einem Blatt befasst
Sub Echelle_Feuille_Vues()
'MEP changer l'échelle des vues
'1 : Bouton radio "échelle de la feuille"
'2 : Échelle personnalisée
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim Part As DrawingDoc
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim swView As SldWorks.View
Dim swSelMgr As SldWorks.SelectionMgr
Dim bRet As Boolean
Dim currentSheet As Sheet
Dim vScaleRatio As Variant
Dim boolstatus As Boolean
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set Part = swApp.ActiveDoc
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
Set swView = swDraw.GetFirstView
Set swSelMgr = swModel.SelectionManager
'Feuille
Set currentSheet = Part.GetCurrentSheet
'vScaleRatio = currentSheet.GetProperties '2-Éch. perso.
'Debug.Print ("Échelle Feuille = " & vScaleRatio(2) & " : " & vScaleRatio(3))
'a = vScaleRatio(2) '2-Éch. perso.
'b = vScaleRatio(3) '2-Éch. perso.
'Vue
While Not swView Is Nothing
vScaleRatio = swView.ScaleRatio
'Debug.Print ("Échelle vue = " & vScaleRatio(0) & " : " & vScaleRatio(1))
'swView.ScaleDecimal = a / b '2-Éch. perso.
'Bouton radio "utiliser l'échelle de la feuille"
swView.UseSheetScale = True '1-BT radio
swView.UpdateViewDisplayGeometry '1-BT radio
Set swView = swView.GetNextView
Wend
boolstatus = swModel.EditRebuild
End Sub