Color of SOR
Posted: Tue Sep 05, 2017 10:04 am
Good day,
This is related to my previous post. Thanks for the SOR code, which I implemented. Works nicely, except for 2 points.
Color:
Seems the color of the Hub does not match that of the tooth. Any suggestion ? (code appears below).
Coordinates of the ElSet. From you example, the coordinates are basically a set of (Z, Radius). However, as in the picture just above, some teeth are really twisted and the match of the tooth to the SOR Hub is not quite good. What would be nice would be to use 3D coordinates rather than 2D, i.e. (Z, Y, X).
When I do this the hub really changes shape. Probably not much I can do because the Linestrip follows the tooth, but then maybe do you have a suggestion ?
Code to create a SOR
Code where SOR is called, located and colored
Code where iSection is given color
Thanks, Jeff
This is related to my previous post. Thanks for the SOR code, which I implemented. Works nicely, except for 2 points.
Color:
Seems the color of the Hub does not match that of the tooth. Any suggestion ? (code appears below).
Coordinates of the ElSet. From you example, the coordinates are basically a set of (Z, Radius). However, as in the picture just above, some teeth are really twisted and the match of the tooth to the SOR Hub is not quite good. What would be nice would be to use 3D coordinates rather than 2D, i.e. (Z, Y, X).
When I do this the hub really changes shape. Probably not much I can do because the Linestrip follows the tooth, but then maybe do you have a suggestion ?
Code to create a SOR
Code: Select all
' Create new Surface Of Revolution Object
'
Function CreateSOR(ByRef IDesWin As Int32, _
ByRef NPts As Int32, _
IsClosed As Boolean, _
ByRef V1() As Double, _
ByRef V2() As Double, _
ByRef V3() As Double) As ISection
Dim Ii As Int32
Dim iModel As IModel = ChildWindow(IDesWin).AxKCad.GetModel()
Dim iGenerator As IDIObjGenerator = iModel
Dim iSorGenerator As ISORSectionGenerator = iGenerator.Create(EObjectType.eObjTypeSORGenerator)
' Some initial structure. Can be changed later
' # Segments; Closed or not; type; etc.
'
Dim iSORinfo As DISectInfo = New DISectInfo
iSORinfo.closed = True
iSORinfo.segments = NPts - 1
iSORinfo.radius = 20.0
iSORinfo.segmentType = ESegmentType.eSegmTypeLine
iSORinfo.regularJoints = False
' Create the Section based on the info given
'
Dim iSection As ISection = iSorGenerator.Create(iSORinfo)
' Add the Section to the Model
'
Dim iArray As IArray = iModel
iArray.Add(iSection)
' Define the strip segment for the SOR
'
Dim iStrip As IStrip = iSection
Dim iEl As IElement
Dim IsXYZ As Boolean = False ' True
' Set the points in the SOR Strip
'
For Ii = 1 To NPts
IEl = iStrip.GetElement(Ii-1, False)
' Coordinates given as (X, Y, Z)
If IsXYZ Then
iEl.SetParam(2, V1(Ii)) ' X
iEl.SetParam(1, V2(Ii)) ' Y
iEl.SetParam(0, V3(Ii)) ' Z
' Coordinates given as (Z, Radius)
Else
iEl.SetParam(0, V3(Ii)) ' Z
iEl.SetParam(1, Math.Sqrt(V1(Ii)^2 + V2(Ii)^2)) ' Radius
End If
Next
Return iSection
End Function
Code: Select all
'****************************************
' Creation SOR
'****************************************
Dim iSection As ISection = CreateSOR(IDesWin, NPts, True, V1, V2, V3)
' Put it in position
'
Call KCiSectionTransform(iSection, Gen, AngRot)
' Give it Color
'
Call SetKCiSectionColor(iSection, IColor)
' Update Surface
'
ChildWindow(IDesWin).AxKCad.UpdateSurface()
Code: Select all
Sub SetKCiSectionColor(ByRef iSection As ISection, _
ByRef IColDes As Int32)
Dim IRed, IGreen, IBlue As Int32
Dim Red, Green, Blue As Decimal
Dim IMatl As IMaterial = iSection
Call GetRgbFt(IColDes, IRed, IGreen, IBlue)
Red = IRed / 255
Green = IGreen / 255
Blue = IBlue / 255
IMatl.SetColor(0, Red, Green, Blue)
IMatl.SetColor(1, Red, Green, Blue)
End Sub