Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Updating iPart Weights

10 REPLIES 10
Reply
Message 1 of 11
jonbrabbs
758 Views, 10 Replies

Updating iPart Weights

Morning All,



Does anyone know if it is possible to update the weight if iParts? I've been trying to write some code to scroll through each line of the iPart table, and generate the weights for each variant (about 30 of them), but don't seem to be getting anywhere.



Any help would be appreciated (even if it's "No! You can't do that.")



Many thanks



Jon
///////////////////////////////////////////////////////////////////////////////////////////////////
If this post helps you, please give kudos.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: jonbrabbs


I thought this was an interesting question and went
ahead and added a post to my blog that discusses it.  See:



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Morning
All,



Does anyone know if it is possible to update the weight if
iParts? I've been trying to write some code to scroll through each line of the
iPart table, and generate the weights for each variant (about 30 of them), but
don't seem to be getting anywhere.



Any help would be
appreciated (even if it's "No! You can't do that.")



Many thanks




Jon
Message 3 of 11
jonbrabbs
in reply to: jonbrabbs

Brian,



Many thanks. Once again you've made my life just a little bit easier!



Jon
///////////////////////////////////////////////////////////////////////////////////////////////////
If this post helps you, please give kudos.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Message 4 of 11

i have tried coping and pasting the code and im getting a error:

Compile error:
Syntax error

and when i hit ok on the error dialog box it highlights the first line in the code.

what am i doing wrong?

jeremy
Message 5 of 11

ok i found the problem myself,

it works great one thing though......

can you modify the code to where you can override the weight in the factory for each member and it will
keep the override weight.

for instance if i have a family of valve im going to model the profile of the valve but not its guts
so my weight will be off. i need to be able to override the weight in an ipart.

can you please email me the modified code for this if its not to much of an inconveinace for you.
jeremy.chaisson@exterran.com

Thanks, Jeremy
Message 6 of 11
jonbrabbs
in reply to: jonbrabbs

Jeremy,



I as understand the code, it simply puts a value into excel, for use in a custom iProperty.



Therefore, the actual weight can be over-ridden in the spreadhsheet with whatever value you choose to use, and this will then be shown in the custom iProperty.



The actual weight of the component will only affect the BOM weight which is drawn from the model, however it should eb possilbe to get the BOM to use the custom weight.



If you know the weight of all the gubbins inside your valve, it should be possible to mod the code, so that strWeight = the actual model weight & the weight of the internals & kg. This could be done in the code or thru excel, so that you have the actual model weight and then in the cell next to it, you could have that + an amount.



Hope that helps.



Jon
///////////////////////////////////////////////////////////////////////////////////////////////////
If this post helps you, please give kudos.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Message 7 of 11

Jon,

what i need is for the custom iprop "Weight" to be able to over write the mass prop in the iproperties.

if you over write the mass prop in a single part file it is easy

if you try and do the same in an ipart it uses the same wieght for all members of that ipart, witch is why im
having this problem im not modeling these valves perfect just the envolope size and shape so the default weights are coming out wrong.

i dont know code enough to mod it myself to be able to do what i need thats the help im trying to find.

try this and you will see what i mean..........
....take one of your iparts copy it and rename it to ???????
....over write the mass in the iproperties to 10.000
....save file
....run the code
....now go to edit table
look at the custom iprop "Weight" every member has the same mass "10.000"

Jeremy
Message 8 of 11
jonbrabbs
in reply to: jonbrabbs

Hi Jeremy,



Ok, I think I know what you mean. Essentially you want to run the code backwards, and copy the information from the iPart spreadsheet, and copy this into iProperties.



According the help file, the Mass property can be written to, so modifying Brian's code should allow you to do this.



Not sure of the specifics but, if you try changing the current code for this:



From Here:


' Iterate through the rows

Dim oRow As iPartTableRow

Dim strWeight as String

For Each oRow In oFactory.TableRows

' Make this the active row so the model will recompute.

oFactory.DefaultRow = oRow

' Set the row value for the weight column.

strWeight = oRow.Item(iWeightColumnIndex).Value

' Overwrite the iProperty.

oPartDoc.ComponentDefinition.MassProperties.Mass = strWeight

Next

End Sub



I've not tested this, so you'll have to let me know if it works. If not, I'll have a play with it during the week and re-post. You may need to set your spreadsheet values to those similar to your default iProperty values (eg x.xxx kg).



Good luck, let me know how you get on.



Jon

///////////////////////////////////////////////////////////////////////////////////////////////////
If this post helps you, please give kudos.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Message 9 of 11

Jon,

it looks like all the code is right but the last line.

im getting a " Type mismatch" error.

any ideas?

Jeremy,

P.S. Thanks for the help so far your awsome.
Message 10 of 11
jonbrabbs
in reply to: jonbrabbs


Jeremy,



Hmmmmmmmm.......



I've spent a bit of time on this, and it seems to not be as straight forward as I thought (somewhat unsuprisingly - very little ever is!)



It seems that whilst it is possible to override the weight (I've got it to do this on save), it only updates the active part. This would mean that you had to save each part individually, thus negating the benefit of iParts. Also when put into an assembly, it reverts back to its calculated weight - irritating.



I'll have a ponder over it, as and when I get chance, and get back to you.



Hmmmmmmmm.......



Jon

///////////////////////////////////////////////////////////////////////////////////////////////////
If this post helps you, please give kudos.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Message 11 of 11
Greatwhitenorth
in reply to: jonbrabbs

Hi Jon,

 

I'm interested in this too.  Did you ever figure it out?

 

Thanks in advance.

 

Bob

____________________________________________________
Product Design & Manufacturing Collection 2021 | Vault Professional 2021
Dell Precision 7670 | Intel i7-12850HX - 2100 Mhz - 64GB
nVIDIA RTX A3000 12GB | Windows 10/64 Pro

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report