iLogic driving and driven dimensions

iLogic driving and driven dimensions

iiiocep
Advocate Advocate
990 Views
5 Replies
Message 1 of 6

iLogic driving and driven dimensions

iiiocep
Advocate
Advocate

Hi everyone, I have some problems with my code:

 

Terms:

1. d64 - driving dimension

2. d75 - driven dimension

 Solution is:

1. Проверяем является ли параметр "d64" управляющим.

2. Если условие выполняется, то параметр "d75" нужно сделать управляемым и присвоить ему какое-то значение .

0 Likes
Accepted solutions (2)
991 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

What language are you using?  If you translate it to English, you may get more responses.

You can use Google Translate or https://www.translate.com/ , if needed.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

iiiocep
Advocate
Advocate

I don't know why, but I delete the translation to English.

1. Check if the parameter "d64" is driving it works correct.

2. If the first condition is True parameter "d64" should be driving too and I need to assign new value to it.

I think I have some problems with connection of two conditions, because both conditions works separately correct.

0 Likes
Message 4 of 6

iiiocep
Advocate
Advocate

I don't know why, but I delete the translation to English.

Full question:

Hi everyone, I have some problems with my code:

Terms:

  1. d64 - driving dimension
  2. d75 - driven dimension

 Solution that I tried is:

  1. Check if the parameter "d64" is driving it works correct.
  2. If the first condition is True parameter "d64" should be driving too and I need to assign new value to it.

I think I have some problems with connection of two conditions, because both conditions works separately correct.

 

Dim oDoc As PartDocument

oDoc = ThisDoc.Document

Dim oSketch1 As Sketch

oSketch1 = oDoc.ComponentDefinition.Sketches.Item("Sketch1")

'Loop through dimensions looking for the one named d64


For Each cDim As DimensionConstraint In oSketch1.DimensionConstraints

   If cDim.Parameter.Name = "d64" Then

        If cDim.Driven = False Then
                     

                If cDim.Parameter.Name = "d75" Then

                If cDim.Driven = True Then

                cDim.Driven = False

         End If   
End If        

     End If

     Exit For

   End If

Next
0 Likes
Message 5 of 6

J-Camper
Advisor
Advisor
Accepted solution

I think this is doing what you're asking:

Dim oDoc As PartDocument = ThisDoc.Document

Dim oSketch1 As Sketch = oDoc.ComponentDefinition.Sketches.Item("Sketch1")

'Declare Dimension Constraints
Dim DimCon1 As DimensionConstraint
Dim DimCon2 As DimensionConstraint
For Each cDim As DimensionConstraint In oSketch1.DimensionConstraints
	If cDim.Parameter.Name = "d64" Then DimCon1 = cDim 
	If cDim.Parameter.Name = "d75" Then DimCon2 = cDim
Next

'Run Logic for which Value to change
If DimCon1.Driven = True
	DimCon2.Driven = False
	'Set Value
	DimCon2.Parameter.Expression = "1 in"
Else 
	'Set Value
	DimCon1.Parameter.Expression = "1 in"
End If

'UPDATE
InventorVb.DocumentUpdate()

Let me know if you have any questions or if the code is not doing what you want. 

 

I would recommend changing the names of Parameters you're going to write rules for instead of leaving them with the given name

Message 6 of 6

iiiocep
Advocate
Advocate
Accepted solution

Hi, thank's a lot for your help! You was almost right.

The code that I want to get and it works:

Dim oDoc As PartDocument = ThisDoc.Document

Dim oSketch1 As Sketch = oDoc.ComponentDefinition.Sketches.Item("Sketch1")

'Declare Dimension Constraints
Dim DimCon1 As DimensionConstraint
Dim DimCon2 As DimensionConstraint
For Each cDim As DimensionConstraint In oSketch1.DimensionConstraints
	If cDim.Parameter.Name = "d64" Then DimCon1 = cDim 
	If cDim.Parameter.Name = "d75" Then DimCon2 = cDim
Next

'Run Logic for which Value to change
If DimCon1.Driven = False
	DimCon2.Driven = False
'Set Value DimCon2.Parameter.Expression = "a12" End If 'UPDATE InventorVb.DocumentUpdate()

 

0 Likes