Vinoth Kanna

Get file name of parts in assembly in solidworks API

Discussion created by Vinoth Kanna on Nov 28, 2020
Latest reply on Nov 28, 2020 by Fifi Riri

Dear All,

I am trying to get file name of parts in assembly. In the order of design tree. Once I got the file name in order, I will use the file name  in my code. 

 

The below code I am using for single part, which is working fine for active windows in solid works.

But I don't aware of how to get file name of every part in assembly in tree order and store them in same order in a String. So I will use the String to control each part.

 

 

'Get File Name
Dim strForgePath As String
strForgePath = Mid(Part.GetPathName, Len(Part.GetPathName), InStrRev(Part.GetPathName, "\"))

 

'Forge Parameters
'Internal Diameter
txtInternalDiameter.Text = Part.Parameter("Internal Diameter@Shell & Thickness@" & strForgePath).Value

 

 

What I am expecting in Code Format:

 

'Get File Name of Active Assembly:

strAssemblyPath = ??!!

 

'Get File Name of Part1

strPart1Path = ??!

 

'Get File Name of Part2

strPart2Path = ??!

 

and so on!!

 

Then i will use above string in below code:

'Forge Parameters
'Internal Diameter
txtInternalDiameter.Text = Part.Parameter("Internal Diameter@Shell & Thickness@" & strPart1Path "@"strAssemblyPath).Value

 

Please do the needful.

Deepak Gupta, Fifi Riri

 

Thanks & Regards,

Vinoth Kanna.D

Outcomes