I need a macro to rename the default plans. How can I recognize the default plans as some of them have already been renamed in some parts?
Heres a vba class that handles default planes independent of name
I quickly created a short example of using it... you will have to set any batch processing up yourself.
Each time you process a new part or assembly just set the model property of the class to the active doc (see line 12)
Works for parts and assemblies, macro attached
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim dp As DefaultPlanes
Dim swFeature As SldWorks.Feature
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set dp = New DefaultPlanes
Set dp.Model = swModel
dp.Front.Name = "MyNewFrontPlane"
dp.Top.Name = "MyNewTopPlane"
dp.Right.Name = "MyNewRightPlane"
Private swDatum As SldWorks.Feature
Private swModel As SldWorks.ModelDoc2
Public Property Set Model(m As SldWorks.ModelDoc2)
Select Case True
Case m Is Nothing: Call Terminate
Case m.GetType = swDocumentTypes_e.swDocPART _
, m.GetType = swDocumentTypes_e.swDocASSEMBLY
Set swModel = m
Private Sub Class_Initialize(): Debug.Print "Lazy init": End Sub
Private Function Initialize()
Set swDatum = swModel.FirstFeature
Do While swDatum.GetTypeName2 <> "RefPlane"
Set swDatum = swDatum.GetNextFeature
Public Property Get Front() As SldWorks.Feature
Set Front = IIf(swDatum Is Nothing, Nothing, swDatum)
Public Property Get Top() As SldWorks.Feature
Set Top = IIf(swDatum Is Nothing, Nothing, swDatum.GetNextFeature)
Public Property Get Right() As SldWorks.Feature
Set Right = IIf(swDatum Is Nothing, Nothing, swDatum.GetNextFeature.GetNextFeature)
Private Sub Class_Terminate(): Call Terminate: End Sub
Private Function Terminate(): Set swModel = Nothing: Set swDatum = Nothing: End Function
Do you really need a macro for this as manually renaming them is so easy????
I think you do not know Italian managers ...
Normally a macro of this type will be set up to traverse the feature manager tree. The default planes with be the first three planes the macro finds.
thank you sooooooooooooooooooooooooo much Rob
my manager is proud of me
I have another question for you... but more difficult...
is it possible to check the opening of a file of the names of the floors, and if they do not correspond to those I wanted, does it change automatically?
ps: sorry my english...
Retrieving data ...