×
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

Assembly controlled properties

Assembly controlled properties

Assembly controlled properties

(OP)
I've seen Handleman's post on controlling properties of parts based on the parent assembly, and it seems like it could help me with something I've been trying to accomplish for a while now.  I don't get exactly how it works, and the new API help file just confuses me.  My goal is (seems) pretty simple, so let's see what you guys can come up with...

I have a few assemblies, assy1.sldasm, assy2.sldasm, etc.  In each assembly there will be a part called insulation.sldprt.

I would like to put a value into each assembly that will then add that value to a given custom property in insulation.sldprt.  That way, insulation.sldprt will never need to be updated itself, just the value in the assembly depending on how much insulation it uses.

To help you understand my goal, we have a utility that imports BOM information from an open assembly directly into our ERP.  So when an assembly is opened and imported, the assembly drives the property of insulation.sldprt, which would eliminate the need for multiple configurations.

I hope you can understand what I'm trying to say here, and any and all input will be greatly appreciated.

Thanks,
Matt

RE: Assembly controlled properties

How would the value you want be determined by the assembly?

-handleman, CSWP (The new, easy test)

RE: Assembly controlled properties

(OP)
That is open for suggestion.

I was thinking there could be a custom property in the assembly called InsQty or something.  This would be changed by the engineer, and when the assembly is rebuilt, it reads that value, and adds it to a config specific property called M2MQty in insulation.sldprt.

That way the insulation quantity is saved per assembly, and insulation.sldprt is just there to for importing the BOM.

RE: Assembly controlled properties

(OP)
Has anyone come up with anything for this?  I've been trying a few different variations of the original code, but I have had no luck so far.

RE: Assembly controlled properties

So what code have you tried?

The code as posted goes through every single document and adds quantity.  All you need to do is make it check the file path to see if it contains "insulation.sldprt". If it does, you get the custom property value from the assembly and add it to the part.  If not, ignore it.

-handleman, CSWP (The new, easy test)

RE: Assembly controlled properties

This may be a good candidate for the virtual components introduced in 2008.  That would keep you from generating an insulation.sldprt for each assembly.

Eric

RE: Assembly controlled properties

See if you can drive the part property from an assembly design table.  Not exactly sure if it's possible, but worth a try.

Another option might be to have an equation at the assembly level drive a parameter at the part level.

RE: Assembly controlled properties

(OP)
handleman,
I've tried a bunch of different code.  The main problem is that when the code doesn't work, it just shows "???" for the equation, so I don't know what exactly is causing the problem.  What is the purpose of breaking the code up into two different properties?  Why wouldn't it work if you just put it into one?

EEnd,
Initially, I tried using virtual components, but had a few different reasons as to why that would not work.  The way I see this working, there will actually only be one file that is used in every assembly.  The part file only changes temporarily when it is opened, and is never actually saved (PDM).  All the info is stored in the assemblies, and is passed down to the part file when they are opened/rebuilt.

TheTick,
I want to stay away from DTs if at all possible.  I want this to be as automatic as possible.  Your second option is basically what I'm trying to accomplish based on handleman's code.

RE: Assembly controlled properties

The reason it's in two properties is that there's a limit on how many characters can be put into a custom property.

The code should work the same for the most part whether it's run from the VBA editor or from the equation.  The main difference is that with the equation you automatically get the ModelDoc2 object for the document owning the equation as the variable called "Part", and the SldWorks.SldWorks object as the variable called "swApp".  Just paste the code into a new macro and add declarations/initialization code for "Part" and "swApp" and you should be able to run/debug from VBA window.

Incidentally, the automatic "Part" variable is key for making the code work as intended in the equation - you can't use ActiveDoc in the equation, because the equation could be evaluated while some other document is the active document.  The only way for the code to know which document "owns" it is by this automatic "Part" variable.

-handleman, CSWP (The new, easy test)

RE: Assembly controlled properties

(OP)
Ok, now I understand.  I got it working, and now I just have to tweak some data to make sure the numbers are correct.  I was able to condense everything into one property with the following code:

1
Dim myAsy As AssemblyDoc
Dim myCmps
Dim CmpDoc As ModelDoc2
Dim i As Long
Dim InsQty As Long
Dim myCmp As Component2
Set myAsy = Assembly
InsQty = myAsy.CustomInfo("InsQty")
myCmps = myAsy.GetComponents(True)
For i = 0 To UBound(myCmps)
Set myCmp = myCmps(i)
If instr(myCmp.GetPathName, "Insulation.SLDPRT") Then
Set CmpDoc = myCmp.GetModelDoc
CmpDoc.DeleteCustomInfo2 "Default", "M2MQty"
CmpDoc.AddCustomInfo3 "Default", "M2MQty", 30, InsQty
End If
next i

So once the appropriate data is in the assembly, all I have to do is change the property "InsQty" and the part file will be updated upon rebuild.

Thanks for the help

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