AnsweredAssumed Answered

GetComponent fails

Question asked by Janos David Ommert on Oct 3, 2015
Latest reply on Oct 5, 2015 by Janos David Ommert

I have a case in which GetComponent fails. (returns nothing)


I have a assembly with some components in it. There are 2D sketches with points on the assembly. The sketches are referenced to the surfaces of the components but belong to the assembly. Maiby thats the problem why GetComponent fails.


I need to get the normal vector of the surface the points are on. It's for export into a csv file for processing by a laser tracker.

I can get the normal vector without problems but it's relativ to the components origin. I need it relativ to the assemblys origin. So i need to transform it. For that i need to get the transformation of the component. To get the transformation i need to get the components object. And thats the point my code fails.

"Set Component = Entity.GetComponent" Component is nothing.


Anything i am doing wrong?

Is there another way to get the transform?


            'get face of the sketch
            Set SketchFace = swSketch.GetReferenceEntity(EntityType)
            'check if sketch was been made on a face
            If EntityType <> swSelFACES Then
                MsgBox "Die Skizze hat keine Fläche als Referenz: " & swFeat.Description, vbCritical
                Exit Sub
            End If
            'get normal of face
            NormalArray(0) = SketchFace.Normal(0)
            NormalArray(1) = SketchFace.Normal(1)
            NormalArray(2) = SketchFace.Normal(2)
            'transform normal to assembly origin
            Set NormalVector = swMathUtil.CreateVector(NormalArray)
            Set Entity = SketchFace
            Set Component = Entity.GetComponent
            Set NormalVector = NormalVector.MultiplyTransform(Component.Transform.Inverse)
            NormalX = NormalVector.ArrayData(0)
            NormalY = NormalVector.ArrayData(1)
            NormalZ = NormalVector.ArrayData(2)