×
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

What is the API for "Insert Part into Assy?"

What is the API for "Insert Part into Assy?"

What is the API for "Insert Part into Assy?"

(OP)
1)How to insert part/assy into current assembly through API?
All the functions I have found so far allow inserting already loaded parts... Say I know the file source. How to get to the place where SW asks for placement of component?

2)Not API question: some files show preview of model when dragging from Feature Palette. Why some don't?

Linqur

RE: What is the API for "Insert Part into Assy?"

Not sure on question #1.

Question #2....Not API question: some files show preview of model when dragging from Feature Palette. Why some don't?

Some reason for this may that the SW file was created in another version.  If it is a SW2000 file I do not believe that you will see a preview when opening it up in 2001+ until it is saved.  Another reason may may that when this file was last opened their may have been a crash or improper shut down.

BBJT CSWP

RE: What is the API for "Insert Part into Assy?"

I don't know why you would want this operation to be automated when it is so simple to insert a new file into a pre-existing assembly and mate it to boot. You can use smartmates or the old fashion way that I prefer of manually building your mates.

Could you elaborate on why? Just for my insane curiousity.

Just a thought...even if you make or get a program that inserts the component that you desire. You will still have to manually pick the faces or planes you want to use. So why spend the exhausting hours of making a program that does some of the steps for you. when in the long run your going to still have to tell it which face or plane you want to use. You could spend less time doing it manually rather than writing a program...just a thought.

I could be wrong on that though...

Best Regards,

Scott Baugh, CSWP
credence69@REMOVEhotmail.com
http://home.insightbb.com/~scott.baugh/

RE: What is the API for "Insert Part into Assy?"

This may help, email me or post a more specific question if needed.  Don't know about the preview thing yet.

Dim swApp As Object
Dim swAssy As Object
Dim swPart As Object

Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set swAssy = swApp.ActiveDoc
swApp.LoadFile2 "C:\Sw Temp Files\Part1.SLDPRT", ""
Set swPart = swAssy.AddComponent2("C:\Sw Temp Files\Part1.SLDPRT", 0, 0, 0)
'You could then use the pointer to the
'AssemblyDoc and PartDoc
'to relocate after it has been inserted == swAssy and swPart
End Sub

Bill Briggs, CSWP

RE: What is the API for "Insert Part into Assy?"

(OP)
Thanks
BBJT: I think it is a guite reasonable. I had doubts that
this might also depend on whether Mate Reference in created...(?)


SBaugh: Our files are situated in folders based on file
name. So if I decide to use part with certain code then I
deduct the file path from the code and from there on
I want to automate everything until mating.

BillBriggs: this seems at first look just what I have been looking for! I need to test it more.

br,
Llinqur

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