Within an IvAdoptedPart I drive a hole with the following code:
Child hole As :IvPartHoleFeature
diameter=10
cboreDiameter=15
cboreDepth=12
face="oben"
edge1="links_oben"
edge2="vorne_oben"
distance1=50
distance2=120
biasPoint="Ursprung"
throughAllType=:ThroughAll
extentDirection=:positive
End Child
Now I would like to change the color of the hole feature:
Rule TestColor As Boolean
Dim InventorComponent As Any = gethostobject(Me).definition.document
Dim NewRenderStyleObject As Any = InventorComponent.RenderStyles.get_Item("Red")
Dim oPartFeature As Any = GetHostObject(hole)
oPartFeature.SetRenderStyle(StyleSourceTypeEnum.kOverrideRenderStyle, NewRenderStyleObject)
Return True
End Rule
Changing the color does'nt work. What's wrong?
I'm working with Inventor ETO 2014.
Thanks,
Dieter
Solved! Go to Solution.
Solved by AlexKorzun. Go to Solution.
Why you didn't try to create hole in factory file and suppress/unsuppress feature if necessary?
I've added the Inventor namespace into enumeration, and "it works".
' Written by Intent
Design aaa : ETO_SamplesRoot PartHole_Part01
'
Child simpleLinearHole As :IvPartHoleFeature
face = "TopFace"
edge1 = "TopFrontEdge"
edge2 = "TopLeftEdge"
distance1 = 11
distance2 = 12
biasPoint = "v001"
extentDirection = :Positive
diameter = 10
cboreDiameter = 15
cboredepth=12
throughAllType = :throughAll
End Child
Rule TestColor As Any
Dim InventorComponent As Any = gethostobject(Me).definition.document
Dim NewRenderStyleObject As Any = InventorComponent.RenderStyles.get_Item("Red")
Dim oPartFeature As Any = GetHostObject(simpleLinearHole)
oPartFeature.SetRenderStyle(Inventor.StyleSourceTypeEnum.kOverrideRenderStyle, NewRenderStyleObject)
'
Return oPartFeature
End Rule
End Design
Hi Alex
That works fine now.
Can you please tell me how to add a parameter named "color" to the IvPartHoleFeature design that colors the feature directly?
Thanks
Dieter
Hi Dieter,
Though it might change in future, please try overriding the modelself Rule for the part with the hole chile, injecting the code:
' Written by Intent
Design aaa : ETO_SamplesRoot PartHole_Part01
'Add the drilled hole feature
Child simpleLinearHole As :PartHoleFeaturewithcolor
'drilledType = :Drilled
face = "TopFace"
edge1 = "TopFrontEdge"
edge2 = "TopLeftEdge"
distance1 = 11
distance2 = 12
biasPoint = "v001"
extentDirection = :Positive
diameter = 10
cboreDiameter = 15
cboredepth=12
throughAllType = :throughAll
End Child
< %%category(""), _
%%choices("%%colorChoices"), _
%%PEAllowOther?("True"), _
%%evalChoices("True") > _
Parameter Rule FeatureColor As String = "red"
Rule modelSelf As List
memberPathname
Dim ret As List = { %%updateSelf }
Dim InventorComponent As Any = GetHostObject( Me).definition.document
Dim NewRenderStyleObject As Any = InventorComponent.RenderStyles.get_Item( FeatureColor)
Dim oPartFeature As Any = Gethostobject(simpleLinearHole)
oPartFeature.SetRenderStyle(Inventor.StyleSourceTypeEnum.kOverrideRenderStyle, NewRenderStyleObject)
Return ret
End Rule
Hi Dieter,
The only remaining thing is to mix the FeatureColor into part's signature, if it is required.
The simplest is to create a dummy string parameter, include it into %%paramList.
OR
modify iProperties Rule to containt the similar to:
Parameter Rule iProperties As List = {{"FC", FeatureColor}}