Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

linqur

Mechanical
Mar 10, 2001
100
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
 
Replies continue below

Recommended for you

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
 
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 [spin]
credence69@REMOVEhotmail.com
 
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
 
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. [morning]

br,
Llinqur
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor