Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

API Mate (3-Planes in part to 3-Planes in Assembly)

Status
Not open for further replies.

scottmac

Mechanical
Jan 9, 2002
1
I am trying to get my feet wet with API programming. I have recorded a simple macro which mates 3 planes on a part (FRONT, SIDE, TOP) to 3 planes on the assembly which it is contained in (PLANES have same names.)

I am trying to makes this macro generic so that user can select a floating part in a assembly and the macro will get part name and assembly name and take care of the mates accordingly. I am having trouble getting the assembly name for use in selecting the part planes
(i.e. Assy.AndSelectByID "Top@Part1-1@Assem1", "PLANE", 0, 0, 0)

Part1-1 can be found using Component.Name after using GetSelectedObject()

How do I get Assem1?

I ran across one technique but it puts .sldasm extension.

ANy help would be greatly appreciated.
 
Replies continue below

Recommended for you

To get the name of the active assembly and remove the extension:
Code:
Dim swApp As Object
Dim Part As Object
Dim sAssyName As String

Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc

sAssyName = Part.GetTitle
sAssyName = Left(sAssyName, InStr(1, sAssyName, ".") - 1)

MsgBox sAssyName
Hope this helps. DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor