×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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.

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

To get the name of the active assembly and remove the extension:

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources