Results 1 to 6 of 6

Thread: iLogic change colour depending on the value of a parameter

  1. #1
    Member
    Join Date
    2015-11
    Location
    Tasmania Australia
    Posts
    4
    Login to Give a bone
    0

    Default iLogic change colour depending on the value of a parameter

    Hi, I am designing a large tank as a part that will have about 112 features that will change colour depending on the value of a parameter.

    Below is the code I have working at the moment

    The tank will be covered in colored dots that will represent the wall thickness measure for and existing site tank

    The finished model will look a bit like a heat map showing the thinner areas of the tank.

    When the (wall thickness) parameters change over time the colors of the features will change to reflect the level of corrosion.

    The parameter will be updated manually when the model is revised.

    There will be about 56 parameters and 112 model features, and I was looking for some help in the best way to manage the size of the code without it becoming to huge to manage

    Parameters would be something like

    A0 = 4.6mm
    A1 = 4.9mm

    etc etc

    Code:
    If (A0 < 3.1) Then
    Feature.Color("A0") = ("Red")
    
    End If
    
    If (A0 > 3.1 And A0 <6) Then
    	
    Feature.Color("A0") = ("Orange")
    
    End If
    
    If (A0 > 6) Then
    	
    Feature.Color("A0") = ("Green")
    
    End If
    Any help would be greatly appreciated. I am a weak coder, but I got this to work. Would love to get it in a concise format for the full 56 parameters.

    Thanks in advance
    Last edited by Ed Jobe; 2021-06-16 at 02:25 PM. Reason: Added CODE tags

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,815
    Login to Give a bone
    0

    Default Re: iLogic change colour depending on the value of a parameter

    You could put the parameters in an array and then call a color setting function for each array member.

    Code:
    Sub Main()
    	Dim features(2, 50)
    	features(0, 0) = "A0" : features(1, 0) = 4.5
    	features(0, 1) = "A1" : features(1, 1) = 4.6
    	features(0, 2) = "A2" : features(1, 2) = 4.9
    
    	Dim i As Integer = 0
    	For i = 0 To 50
    		SetFeatureColor(features(0, i), features(1, i))
    	Next i
    End Sub
    
    Function SetFeatureColor(featureID, thickness)
    	Select Case thickness
    	Case thickness < 3.1
    		Feature.Color(featureID) = ("Red")
    	Case thickness >= 3.1 And thickness < 6.0
    		Feature.Color(featureID) = ("Orange")
    	Case thickness >6 
    		Feature.Color(featureID) = ("Green")
    	End Select
    End Function
    C:> ED WORKING....

  3. #3
    Member
    Join Date
    2015-11
    Location
    Tasmania Australia
    Posts
    4
    Login to Give a bone
    0

    Default Re: iLogic change colour depending on the value of a parameter

    Quote Originally Posted by Ed Jobe View Post
    You could put the parameters in an array and then call a color setting function for each array member.

    Code:
    Sub Main()
    	Dim features(2, 50)
    	features(0, 0) = "A0" : features(1, 0) = 4.5
    	features(0, 1) = "A1" : features(1, 1) = 4.6
    	features(0, 2) = "A2" : features(1, 2) = 4.9
    
    	Dim i As Integer = 0
    	For i = 0 To 50
    		SetFeatureColor(features(0, i), features(1, i))
    	Next i
    End Sub
    
    Function SetFeatureColor(featureID, thickness)
    	Select Case thickness
    	Case thickness < 3.1
    		Feature.Color(featureID) = ("Red")
    	Case thickness >= 3.1 And thickness < 6.0
    		Feature.Color(featureID) = ("Orange")
    	Case thickness >6 
    		Feature.Color(featureID) = ("Green")
    	End Select
    End Function
    Hi thanks for you input.

    I am struggling to understand an implement this, probably a bit advanced for me.

    I am not clear on the work flow to make my parameters talk to the features.

    My test part has 4 features
    Test part features.JPG

    The test part has 4 parameters
    Test part parameters.JPG

    When I edit the parameter I am hoping to make the feature with the same name change colour
    The parameter is edited in a form in the part file
    For Wall thickness.JPG

    Every 6 months the tanks has measurements taken and the part will be revised to show the 'at risk' points on the tank.

    Any help is greatly appreciated

    Thanks Peter

  4. #4
    Member
    Join Date
    2015-11
    Location
    Tasmania Australia
    Posts
    4
    Login to Give a bone
    0

    Default Re: iLogic change colour depending on the value of a parameter

    I got it to work with this code, but it is just bulky and clunky

    Code:
    If (A0 < 3.1) Then
    Feature.Color("A0") = ("Red")
    
    End If
    
    If (A0 > 3.1 And A0 <6) Then
    	
    Feature.Color("A0") = ("Orange")
    
    End If
    
    If (A0 > 5.9) Then
    Feature.Color("A0") = ("Green")
    
    End If
    
    If (A1 < 3.1) Then
    Feature.Color("A1") = ("Red")
    
    End If
    
    If (A1 > 3.1 And A1 <6) Then
    	
    Feature.Color("A1") = ("Orange")
    
    End If
    
    If (A1 > 5.9) Then
    Feature.Color("A1") = ("Green")
    
    End If
    
    If (A2 < 3.1) Then
    Feature.Color("A2") = ("Red")
    
    End If
    
    If (A2 > 3.1 And A2 <6) Then
    	
    Feature.Color("A2") = ("Orange")
    
    End If
    
    If (A2 > 5.9) Then
    Feature.Color("A2") = ("Green")
    
    End If
    Last edited by Ed Jobe; 2021-06-17 at 02:12 PM. Reason: Added CODE tags

  5. #5
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,815
    Login to Give a bone
    0

    Default Re: iLogic change colour depending on the value of a parameter

    Can you post your sample part file?
    Also, please use code tags around your code. When you reply, click on the Go Advanced button and it will give you a more advance editor. Select your code and click on the # button and it will wrap your code with code tags.

    This revised code should work. You hardcode the list of features to track using the array. The function gets the parameter value and sets the feature color.
    Code:
    Sub Main()
    	'Build an array of strings representing desired features
    	'Resize the array as needed.
    	Dim features(2)
    	features(0) = "A0" 
    	features(1) = "A1" 
    	features(2) = "A2" 
    	
    	'Iterate the array
    	Dim i As Integer = 0
    	For i = 0 To 50
    		SetFeatureColor(features(i))
    	Next i
    End Sub
    
    Function SetFeatureColor(featureID)
    	Dim thickness As Double = Parameter.Param(featureID).Value
    	Select Case thickness
    	Case thickness < 3.1
    		Feature.Color(featureID) = ("Red")
    	Case thickness >= 3.1 And thickness < 6.0
    		Feature.Color(featureID) = ("Orange")
    	Case thickness >6 
    		Feature.Color(featureID) = ("Green")
    	End Select
    End Function
    Last edited by Ed Jobe; 2021-06-17 at 05:48 PM.
    C:> ED WORKING....

  6. #6
    Member
    Join Date
    2015-11
    Location
    Tasmania Australia
    Posts
    4
    Login to Give a bone
    0

    Red face Re: iLogic change colour depending on the value of a parameter

    Hi here is a test part that works

    There is an embedded form to edit the parameters

    Your code will help a lot though as I need 56 of these parts and each of these have 13 parameters

    The final model will look visually very different, I just wanted to get a working test part so the functionality is correct and the code is concise.

    Thanks Peter
    Attached Files Attached Files

Similar Threads

  1. Replies: 1
    Last Post: 2017-10-04, 07:48 PM
  2. 2017: Family parameter value to acquire host parameter value
    By ray_bongalon in forum Revit Architecture - General
    Replies: 7
    Last Post: 2017-06-13, 11:13 AM
  3. Change all Objects of one colour to another colour
    By tburke in forum AutoCAD General
    Replies: 15
    Last Post: 2016-03-04, 01:53 PM
  4. DB apperance depending on attribute value
    By Macieto in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2014-10-12, 09:44 PM
  5. Replies: 7
    Last Post: 2008-01-29, 06:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •