Inventor Customization

Reply
*Pro
jletcher
Posts: 1,946
Registered: ‎05-18-2011
Message 11 of 16 (150 Views)

Re: Need help creating a rule

10-04-2012 06:32 AM in reply to: fakeru

Ok I am on 2012 also so we will be fine there. I have meeting when I get out I will get her done....


Please mark this response as "Accept as Solution" if it answers your question.

James Letcher
2012 Factory Design Suite ( will not load 2013)
What happen to my Inventor :-(
Valued Contributor
fakeru
Posts: 87
Registered: ‎03-07-2010
Message 12 of 16 (137 Views)

Re: Need help creating a rule

10-06-2012 05:59 AM in reply to: jletcher

Hi  jletcher!

Have you tried or not yet?

AIP 2014
Windows 7 x64
Dell Precision T7400 Intel(R) Xeon(R) CPU X5472 @ 3.00GHz (4 CPU's), 8Gb RAM, NVIDIA Quadro FX 5600 1536MB GDDR3
*Pro
jletcher
Posts: 1,946
Registered: ‎05-18-2011
Message 13 of 16 (126 Views)

Re: Need help creating a rule

10-08-2012 08:47 AM in reply to: fakeru

Yes I am on it just trying to make it faster don't like the way it is updating. So I am trying a few things out.

 

If you go from 500L to 1000L or so lets say it takes a few minutes to complete so I am tryig a few things to speed it up should have it posted later today.

 

Monday is bad for me I have like 10 clients I have to go have meetings with see if they need anything then I should be able to finish it up...


Please mark this response as "Accept as Solution" if it answers your question.

James Letcher
2012 Factory Design Suite ( will not load 2013)
What happen to my Inventor :-(
Valued Contributor
fakeru
Posts: 87
Registered: ‎03-07-2010
Message 14 of 16 (123 Views)

Re: Need help creating a rule

10-08-2012 09:26 AM in reply to: jletcher

ok. take your time, it's not urgent for me. thank you very much for your effort!

AIP 2014
Windows 7 x64
Dell Precision T7400 Intel(R) Xeon(R) CPU X5472 @ 3.00GHz (4 CPU's), 8Gb RAM, NVIDIA Quadro FX 5600 1536MB GDDR3
ADN Support Specialist
Vladimir.Ananyev
Posts: 467
Registered: ‎08-14-2012
Message 15 of 16 (99 Views)

Re: Need help creating a rule

10-16-2012 05:48 AM in reply to: fakeru

I’ve slightly modified parameters in your model and add "optimization" rule that calculates desired height using the simplest iterative bisection (dichotomy) method. 

Result.PNG

'********************************************************
'this rule adjust the value of Height model parameter
'to get the part volume equal to TargetVolume
'********************************************************
'TargetVolume - target volume 
'HLowerLimit - Lower heifht limit - HLowLimit
'HUpperLimit - Upper height limit - HUpperLimit
'NMax - maximal number of iterations - 
'RelErr - Relative error
'********************************************************
'maximal number of iterations
Dim NMax As Integer = 30
'Relative error
Dim RelErr As Double = 0.00001
'********************************************************

ThisDoc.Save

Dim oDoc As PartDocument = ThisDoc.Document
Dim oUOM As UnitsOfMeasure = oDoc.UnitsOfMeasure
Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
Dim oPars As Parameters = oDef.Parameters 
Dim oMassProps As MassProperties = oDef.MassProperties
oMassProps.Accuracy = MassPropertiesAccuracyEnum.k_Medium

'Input data
Dim Hmax As Double = oPars.Item("HUpperLimit").Value
Dim Hmin As Double = oPars.Item("HLowerLimit").Value
Dim Target_Volume As Double = oPars.Item("TargetVolume").Value

'control height. Volume is driven by this parameter
Dim oModelPar As ModelParameter = oPars.ModelParameters.Item("Height")

Dim N As Integer = 0  
Dim H As Double = (Hmin + Hmax) / 2
oModelPar.Value = H
oDoc.Update
Dim V As Double = oMassProps.Volume

Do While (N <= NMax) And (Math.Abs(V - Target_Volume)/Target_Volume > RelErr)
	N = N + 1
	If (V - Target_Volume) > 0 Then
		Hmax = H
	Else
		Hmin = H
	End If
	H = (Hmin + Hmax) / 2
	oModelPar.Value = H
	oDoc.Update
	V = oMassProps.Volume
	ThisApplication.activeview.update
Loop

oDoc.Update
oPars.Item("Current_Volume").Value = V

Dim delta As Double = Math.Abs(V - Target_Volume)/Target_Volume

'report
MsgBox ("N = " & N & vbNewLine & "V = " & _
       oUOM.GetStringFromValue(V, "l") & vbNewLine & _
      "Delta = " & delta)  	  
'********************************************************

Updated version of your part is attached.

Hope this rule is a good start point to move further.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Valued Contributor
fakeru
Posts: 87
Registered: ‎03-07-2010
Message 16 of 16 (88 Views)

Re: Need help creating a rule

10-17-2012 12:43 AM in reply to: Vladimir.Ananyev

This rule looks very good. I think it is just what I need. Probably I will have to tweak it a little bit, as it will run for a multibody part. Hope it will work.

 

Thank you very much Vladimir!

Spasibo!:smileyhappy:

AIP 2014
Windows 7 x64
Dell Precision T7400 Intel(R) Xeon(R) CPU X5472 @ 3.00GHz (4 CPU's), 8Gb RAM, NVIDIA Quadro FX 5600 1536MB GDDR3

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube