Inventor General Discussion

Reply
Active Contributor
johnster100
Posts: 34
Registered: ‎10-11-2010
Message 1 of 7 (467 Views)
Accepted Solution

Set Solid Model's Parameters from Assembly

467 Views, 6 Replies
02-08-2013 06:10 AM

Hi there,

I have created a model using solids in a part file.

 

I have then created an assembly file from this using the 'Make Components' option.

 

From the resulting assembly i would like to insert an iLogic form which lets the user change parameters in the solids model.

 

Is there anyway to do this?

 

I can't use the MakePath option as the solid model is not in the assembly ( i do not want it in the assembly).

 

Could I use some API code to achieve my goal?

 

thanks,

John

*Expert Elite*
mrattray
Posts: 2,470
Registered: ‎09-13-2011
Message 2 of 7 (466 Views)

Re: Set Solid Model's Parameters from Assembly

02-08-2013 06:19 AM in reply to: johnster100

Can you use the link parameter tool to add the assembly's parameters as reference parameters inside the multi-body solid part?

Mike (not Matt) Rattray

Active Contributor
johnster100
Posts: 34
Registered: ‎10-11-2010
Message 3 of 7 (462 Views)

Re: Set Solid Model's Parameters from Assembly

02-08-2013 06:21 AM in reply to: mrattray

Hi Mike,

I've tried that. It creates a cyclic dependency :smileysad:

 

thanks,

John

*Expert Elite*
mrattray
Posts: 2,470
Registered: ‎09-13-2011
Message 4 of 7 (456 Views)

Re: Set Solid Model's Parameters from Assembly

02-08-2013 06:27 AM in reply to: johnster100

I thought that might be the case. You could try passing the parameters through a "dummy part". This would be a geometeryless empty ipt file with the needed parameters in it. You can then place this into the assembly (use the reference bom structure to keep it off your BOM) and use iLogic to pass the parameters to this "dummy part". You can then use the link parameters tool to link your multi-body solid to the "dummy part".

This isn't the most elegant solution, but it does work. Although, I've never tried it with multi-bodies.

Mike (not Matt) Rattray

*Expert Elite*
cwhetten
Posts: 1,051
Registered: ‎09-03-2008
Message 5 of 7 (443 Views)

Re: Set Solid Model's Parameters from Assembly

02-08-2013 07:03 AM in reply to: johnster100

What version of Inventor are you using.  What you want to do is trivially easy with iLogic.  Have you ever used iLogic?

 

-cwhetten

Active Contributor
johnster100
Posts: 34
Registered: ‎10-11-2010
Message 6 of 7 (416 Views)

Re: Set Solid Model's Parameters from Assembly

02-11-2013 12:44 AM in reply to: cwhetten

I am using 2012.

 

I have not managed to achieve changing the parameter with iLogic as the part with the parameters is not in the assembly so i cannot use the 'Make Path' function.

 

I was thinking I might need some code which opens the part, updates the parameters, then closes it.

 

I have not placed the solids model in the assembly as it will often contain errors (the red cross appears as some 'Cut' features are having no effect). I do not want my assembly file to dispay the red cross as this may cause concern for the users.

 

thanks,

John

*Expert Elite*
cwhetten
Posts: 1,051
Registered: ‎09-03-2008
Message 7 of 7 (386 Views)

Re: Set Solid Model's Parameters from Assembly

02-15-2013 02:15 PM in reply to: johnster100

johnster100 wrote:

...the part with the parameters is not in the assembly...

 


This complicates things quite a bit.  But, it's still possible.

 


johnster100 wrote:

I was thinking I might need some code which opens the part, updates the parameters, then closes it.

 


This is the same conclusion I came to.  See the attached assembly for an example of how to do this.  Also, for others' benefit, here is the code:

------------------------------------

'Get the component that is derived from the master part.  Change the name of "_ThePart" to match one of your components
oPartDoc = Component.InventorComponent("_ThePart")

'Get the full path and name of the master part
oDerivedSourcePartFullName = oPartDoc.Definition.Document.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).ReferencedDocumentDescriptor.FullDocumentName

'Open the master part in memory so that the parameters will be accessible
oDerivedSourcePart = ThisApplication.Documents.Open(oDerivedSourcePartFullName, False)

'Set the values of d0 and d1 in the master part.  This value is expected in database units, cm,
'so we divide by 1 cm to tell Inventor to convert it to cm, so it will handle the units properly.
'Change the names of "d0" and "d1", and "Width" and "Height" to match your parameter names.
oDerivedSourcePart.ComponentDefinition.Parameters.Item("d0").Value = Width/1 cm
oDerivedSourcePart.ComponentDefinition.Parameters.Item("d1").Value = Height/1 cm

'Get the set of all open, visible documents
allVisibleDocs = ThisApplication.Documents.VisibleDocuments

'Create a test variable and set its default value
docIsVisible = False

'Test if the master part is in the set of open, visible documents.  If so, sets the test variable to True
For Each oDoc In allVisibleDocs
    If oDerivedSourcePart.InternalName = oDoc.InternalName Then
        docIsVisible = True
    End If
Next

'If the document is open and visible, then leave it open.  If it is not, then close the document.
If docIsVisible Then
    'do nothing

Else
    oDerivedSourcePart.Close

End If

iLogicVb.UpdateWhenDone = True

------------------------------------

 

The only way I could get this to work is to get the filename and path of the master part and then open it in memory.  It seems to me that there is probably a better way to do this, but I can't figure it out.  If Curtis sees this thread, maybe he can offer some advice on a better way to write the code.

 

But, it seems to work.  If you change the value of the Width or Height parameters in the assembly, the derived part gets updated.  This would also work if you have many parts in your assembly that are all derived from the same master part (which is usually the case with multi-solid modeling).  All you need to change is the name of the component that it gets (you only need to get one component, not every component that is derived), and the names of your parameters.  You can also add more parameters as needed.

 

-cwhetten

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

 

 

 

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