Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

user selectable dim in driven part

Status
Not open for further replies.

dgiy

Chemical
May 5, 2003
89


SW 2003 SP3.1

I have a part that consists of a flange with a nipple.
The part is table driven and for the various sizes works fine.
However, I would like to have the nipple length variable.
Is it possible (easily possible) to require the person inserting the part to type in a dim valve for the nipple length when the part is inserted?

e.g. User selects version of part he wants and a dialog pops up asking for nipple length.
This would be useful.

Thanks in advance,
DG
 
Replies continue below

Recommended for you

You can have an assmebly DT and in the DT you can have a program the specifies certain parts. You would have to have all the parts pre-made. Then the DT would ask for a Size and you pick out out pre-made config of the nipple.

I'm not sure if this is what your looking for but here are some Examples of some of my previous work.


These are small programs I wrote using DT and VBA

Also at the very bottom there is an article I wrote for Solid Solutions about a year or 2 ago on VBA and SW

I hope that helps,

Scott Baugh, CSWP [frog][elephant2]
3DVision Technologies
faq731-376
When in doubt, always check the help
 
Thanks Scott for your response

Do you have to use VB or can you configure the design table to prompt user when her picks a model

Thanks again,
DG
 
Check out "Data Validation" in excel, or even consider using a library part, which can be made to pop up a prompt, as well.
 
I never used a lot of VB myself I used VBA which is lot like VB but yet totally different.

The above link that has those VBA programs and articles shows you how I accomplished what I was after. I'm hoping it might give you some insight on what your trying to do and if it's possible in VBA or if you think your going to have to use VB. It really depends on what your after and the way your assembly and parts are modeled.

I believe it's possible it's just a matter of figuring out which is the best way.

Be sure to DL and take these files apart from off my website:
VBA Controlled Box
DT Controlled Box
Excel Example
Solid Solutions - can't take this apart but it worth a read or summarize.

Best Regards,

Scott Baugh, CSWP [frog][elephant2]
3DVision Technologies
faq731-376
When in doubt, always check the help
 
This is possible with VB...

You might try by recording a macro then using the VBA interface to add the dialog and customize it to the way you want...

To record a macro...

Start a fresh session of SW... (or just close your file)

Click Tools>Macro>Record

Open Your Part...

Modify the Dimensions you need to...

You Can Save the part if you want to (optional)

Then Stop the macro...
1) on the Macro toolbar that pops up when you start recording
2) Tools>Macro>Stop...
And Save The Macro to a (*.swp) file...

Now Click Tools>Macro>Edit...
And open the (*.swp) file you just saved...

It should look something like this...
Code:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim Annotation As Object
Dim Gtol As Object
Dim DatumTag As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object

Sub main()
  Set swApp = CreateObject("SldWorks.Application")
  Set Part = swApp.ActiveDoc
  swApp.ActiveDoc.ActiveView.FrameState = 1
  swApp.LoadFile2 "C:\Documents and Settings\hbb3336\My Documents\Sldworks_Local\Hole Ex 1.SLDPRT", ""
  Set Part = swApp.ActiveDoc
  Set Part = swApp.OpenDoc4("C:\TEST 1.SLDPRT", 1, 0, "", longstatus)
  swApp.ActiveDoc.ActiveView.FrameLeft = 0
  swApp.ActiveDoc.ActiveView.FrameTop = 0
  swApp.ActiveDoc.ActiveView.FrameState = 1
  Set Part = swApp.ActivateDoc("Hole Ex 1.SLDPRT")
  swApp.ActiveDoc.ActiveView.FrameState = 1
  Part.SelectByID "Base-Extrude", "BODYFEATURE", 0, 0, 0
  Part.ActivateSelectedFeature
  Part.SelectByID "D1@Base-Extrude@Hole Ex 1.SLDPRT", "DIMENSION", 0.1207237397398, 0.02583015579621, -0.05764969775036
  Part.Parameter("D1@Base-Extrude").SystemValue = 0.1778
  Part.ClearSelection
  Part.EditRebuild
  Part.SaveAs2 "C:\TEST 2.SLDPRT", 0, False, False
  Part.Save2 False
End Sub

Notes:
This Opens the document...
Set Part = swApp.OpenDoc4("C:\TEST 1.SLDPRT", 1, 0, "", longstatus)
This Selects the Feature You Selected...
Part.SelectByID "Base-Extrude", "BODYFEATURE", 0, 0, 0
This Activates the Selected Feature...
Part.ActivateSelectedFeature
This Selects the Dimension You Selected...
Part.SelectByID "D1@Base-Extrude@Hole Ex 1.SLDPRT", "DIMENSION", 0.1207237397398, 0.02583015579621, -0.05764969775036
This Sets the Value For the selected Dim...
Part.Parameter("D1@Base-Extrude").SystemValue = 0.1778
*NOTE* ALL VALUES IN SW VBA MUST BE METRIC and/or CONVERTED TO METRIC
This Saves the document with a New Name...
Part.SaveAs2 "C:\TEST 2.SLDPRT", 0, False, False
This Saves the document With The Current Name...
Part.Save2 False

Let Me Know if you need further Help with the VB side...
Hope This Helps, Good Luck

Thanks,
--Josh--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor