I would like to retrieve the name of the configuration of the part used as a reference in a drawing.
Here's the snippet of code I currently have:
We activate the work doc Set swApp = Application.SldWorks Set Part = swApp.ActiveDoc Set FileSys = CreateObject("Scripting.FileSystemObject")
Gets the full path of the current document, including the file name PathName = Part.GetPathName Gets the path to the current document, without the file name: FilePath = Left(PathName, InStrRev(PathName, "\")) Gets the file name: FileName = Right(PathName, Len(PathName) - InStrRev(PathName, "\")) Typedoc = Right(FileName, 3)
Select Case Typedoc Box "drw", "DRW"
Set swview = Part.GetFirstView Set swview = swview. GetNextView 'enables/retrieves the first view for custom properties Set swRefDoc = swview. ReferencedDocument ' We now have swRefDoc the 3D of the drawing
We retrieve the properties of the config of the reference part or assembly configNames = swRefDoc.GetConfigurationNames vConfigNameArr = swRefDoc.GetConfigurationNames
For Each vConfigName In vConfigNameArr Debug.Print vConfigName vCustInfoNameArr = swRefDoc.GetCustomInfoNames2(vConfigName)
except that in "configNames" I get all the configs of the part while I would only want the config of the part used in the drawing and then be able to delete my For Each loop.
Thank you for your help, I'm sure it's bogus for you.
and for a part or assembly, I am looking to have the value of a specific property (e.g. Engineering PartNumber) only present in the "configuration properties" for the configuration of the active part.
Dim swConfigMgr As SldWorks.ConfigurationManager Dim swConfig As SldWorks.Configuration .... Set swConfig = swConfigMgr.ActiveConfiguration ' configuration Active stnameConfig = swConfig.Name 'Active Configuration Name
Dim swCustProp As Variant .... Set swCustProp = swModel.Extension.CustomPropertyManager(swConfig) No_article = swCustProp.Get4("Engineering PartNumber", False, val, valout) No_article = valout 'with dim No_article as string
In the last line of your previous message, the swConfig variable points to an iConfiguration object (in this case swconfig is the current config), not the string containing its name, hence error 13. This is probably swConfig.Name is the string to use (also called stnameConfig by Maclane).