Inventor Customization

Inventor Customization

Reply
Active Contributor
tclayton
Posts: 27
Registered: ‎10-10-2009
Message 1 of 5 (282 Views)
Accepted Solution

Convert model parameter to reference parameter

282 Views, 4 Replies
10-02-2012 07:52 PM

I need to convert a model parameter to a reference parameter thru the API.

I saw this item discussed in the group before, but I cant find the thread.

Can anyone help me out?

Excellent answer, thank you

*Pro
jletcher
Posts: 1,983
Registered: ‎05-18-2011
Message 2 of 5 (267 Views)

Re: Convert model parameter to reference parameter

10-03-2012 11:37 AM in reply to: tclayton
Property Driven() As VARIANT_BOOL

 


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 :-(
Active Contributor
tclayton
Posts: 27
Registered: ‎10-10-2009
Message 3 of 5 (252 Views)

Re: Convert model parameter to reference parameter

10-04-2012 08:29 PM in reply to: jletcher

Sorry, I didn't get that answer.

Has anyone put the " ModelParameter.Convert to Reference Parameter" Method? 

ADN Support Specialist
Vladimir.Ananyev
Posts: 531
Registered: ‎08-14-2012
Message 4 of 5 (227 Views)

Re: Convert model parameter to reference parameter

10-11-2012 12:16 AM in reply to: tclayton

ConvertToReferenceParameter method works fine but not for built-in model parameters. See help.   If you create model parameter programmatically then you are free to call this method. Try the following VBA sample.

 

Private Sub Model2Refs_1()

  Dim oDef As PartComponentDefinition
  Set oDef = ThisApplication.ActiveDocument.ComponentDefinition
  
  Dim oPars As Parameters
  Set oPars = oDef.Parameters
  
  Dim oModelPars As ModelParameters
  Set oModelPars = oPars.ModelParameters
  
  Dim oModelPar As ModelParameter
  'create model parameter (not built-in)
  Set oModelPar = oModelPars.AddByExpression("333 mm", "mm", "NonBuiltIn")
  
  'change its type to reference
  Call oModelPar.ConvertToReferenceParameter
  
End Sub

 

You may control Boolean Driven property of dimension constraints. Create new part with the rectangle on the first sketch + create pair of dimensions (so you will get pair of model parameters). The following VBA code convert parameter which controls the first dimension constraint to reference type.

Private Sub Model2Refs_2()
  
  Dim oDoc As PartDocument
  Set oDoc = ThisApplication.ActiveDocument
  
  Dim oDef As PartComponentDefinition
  Set oDef = oDoc.ComponentDefinition
  
  Dim oSketch As PlanarSketch
  Set oSketch = oDef.Sketches.Item(1)
  
  Dim oDims As DimensionConstraints
  Set oDims = oSketch.DimensionConstraints
  
  Dim oDim As TwoPointDistanceDimConstraint
  Set oDim = oDims.Item(1)
  
  oDim.Driven = True
  
End Sub

 

Hope the idea is clear.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Active Contributor
tclayton
Posts: 27
Registered: ‎10-10-2009
Message 5 of 5 (222 Views)

Re: Convert model parameter to reference parameter

10-11-2012 06:51 AM in reply to: Vladimir.Ananyev

Excellent answer, thank you

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.