Hello, I would like to make a mep that from a room, opens its drawing and saves under the room and the mep under the same name. I made the code below, while testing it, the variables are good but it doesn't work ...
Thank you for your help:)
Sub main()
Set swApp = _
Application.SldWorks
Set swModel = swApp.ActiveDoc
FilePath = swModel.GetPathName
TitleP = swModel.GetTitle
PathSize = Len(FilePath)
PathNoExtension = Left(FilePath, PathSize - 7)
PathMEP = PathNoExtension & ". SLDDRW"
TitleSize = Len(TitleP)
TitleNoExtension = Left(TitleP, TitleSize - 7)
TitleMEP = TitleNoExtension & " - Sheet1"
Set Part = swApp.OpenDoc6(PathMEP, 2, 0, "", longstatus, longwarnings) 'opening source assembly'
swApp.ActivateDoc2 TitleMEP, False, longstatus
Set Part = swApp.ActiveDoc 'activation'
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
bool = swModel.Extension.RunCommand(SwCommands.swCommands_SaveAs, "")
Set swModel = swApp.ActiveDoc
'Recovers the full name of the file
FilePath = swModel.GetPathName
PathSize = Len(FilePath)
PathNoExtension = Left(FilePath, PathSize - 6)
PathMEP = PathNoExtension & ". SLDDRW"
Set Part = swApp.ActiveDoc
longstatus = Part.SaveAs3(FilePathMEP, 0, 2)
End Sub