Hello,
this is my situation. I work mainly with electric workbench . I design harnesses that include the cable and connectors etc. When the harness is fully done i put 3D annotation on the product on the connectores parts to identify their identification number.
I need to be able to insert annotation automaticly. I am able to add this annotation through VBA in a part but not in the product.
If you imagine a cable with 2 connetors on each side that have the same file name i have to have a way to distinguish both when inserting the annotations, one of my ideas it was or using the instance name or even better the reference designator name, but till know i was not able to do it.
Another way i was thinking of doing this it was the VBA create a new part, make new poinst in the new part that correspond to the origin of the parts and then i put all annotation is that new part in those points.
Do not know if i am thinking clearlly but bottomend i just want to be able to put annotation is product strucure and be able to associate the annotation with the part instante name or better the reference designator name.
This is just an example to add anotation in a part, know i insert the annotation stext in the code but futurlly i coud easilly change to import from an excel:
Sub Catstart()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim annotationSets1 As AnnotationSets
Set annotationSets1 = part1.AnnotationSets
Dim annotationSet1 As AnnotationSet
Set annotationSet1 = annotationSets1.Add("VW3D")
Dim annFact As AnnotationFactory
Set annFact = annotationSet1.AnnotationFactory
Dim hb As HybridBody
Set hb = part1.HybridBodies.Item(1)
Dim hbsf As HybridShapeFactory
Set hbsf = part1.HybridShapeFactory
Dim NewPoint As Point
Set NewPoint = hbsf.AddNewPointCoord(0, 0, 0)
NewPoint.Compute
hb.AppendHybridShape NewPoint
Dim sel As Selection
Set sel = CATIA.ActiveDocument.Selection
Dim iX As Double
Dim iY As Double
Dim iZ As Double
iX = 0
iY = 0
iZ = 0
Dim userSurfaces1 As UserSurfaces
Set userSurfaces1 = part1.UserSurfaces
Dim userSurfaceA As UserSurface
Set userSurfaceA = userSurfaces1.Generate(NewPoint)
Dim txt As Text
Dim annot As Annotation
Set annot = annFact.CreateEvoluateText(userSurfaceA, iX, iY, iZ, True)
Set txt = annot.Text
txt.Text = "IDENT:CAS SEAT" & vbCrLf & "FIN: 303NGXX"
part1.Update
End Sub
this is my situation. I work mainly with electric workbench . I design harnesses that include the cable and connectors etc. When the harness is fully done i put 3D annotation on the product on the connectores parts to identify their identification number.
I need to be able to insert annotation automaticly. I am able to add this annotation through VBA in a part but not in the product.
If you imagine a cable with 2 connetors on each side that have the same file name i have to have a way to distinguish both when inserting the annotations, one of my ideas it was or using the instance name or even better the reference designator name, but till know i was not able to do it.
Another way i was thinking of doing this it was the VBA create a new part, make new poinst in the new part that correspond to the origin of the parts and then i put all annotation is that new part in those points.
Do not know if i am thinking clearlly but bottomend i just want to be able to put annotation is product strucure and be able to associate the annotation with the part instante name or better the reference designator name.
This is just an example to add anotation in a part, know i insert the annotation stext in the code but futurlly i coud easilly change to import from an excel:
Sub Catstart()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim annotationSets1 As AnnotationSets
Set annotationSets1 = part1.AnnotationSets
Dim annotationSet1 As AnnotationSet
Set annotationSet1 = annotationSets1.Add("VW3D")
Dim annFact As AnnotationFactory
Set annFact = annotationSet1.AnnotationFactory
Dim hb As HybridBody
Set hb = part1.HybridBodies.Item(1)
Dim hbsf As HybridShapeFactory
Set hbsf = part1.HybridShapeFactory
Dim NewPoint As Point
Set NewPoint = hbsf.AddNewPointCoord(0, 0, 0)
NewPoint.Compute
hb.AppendHybridShape NewPoint
Dim sel As Selection
Set sel = CATIA.ActiveDocument.Selection
Dim iX As Double
Dim iY As Double
Dim iZ As Double
iX = 0
iY = 0
iZ = 0
Dim userSurfaces1 As UserSurfaces
Set userSurfaces1 = part1.UserSurfaces
Dim userSurfaceA As UserSurface
Set userSurfaceA = userSurfaces1.Generate(NewPoint)
Dim txt As Text
Dim annot As Annotation
Set annot = annFact.CreateEvoluateText(userSurfaceA, iX, iY, iZ, True)
Set txt = annot.Text
txt.Text = "IDENT:CAS SEAT" & vbCrLf & "FIN: 303NGXX"
part1.Update
End Sub