Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a new point on screen

Status
Not open for further replies.

Thosnow

Aerospace
Feb 23, 2017
68
Hi All,

How can I create a new point on screen in an active CATPart with a VBA macro? I got to a point as seen below and am stuck.

'================================
Sub AddPoint(Comment As String, part1 As Part)

'//// Get annotation set
Dim annoSet1 As AnnotationSet
Set annoSet1 = part1.AnnotationSets.Item(part1.AnnotationSets.count)

Dim oAnnoFactory As AnnotationFactory
Set oAnnoFactory = annotationSet1.AnnotationFactory

Dim oHybridBody As HybridBody
Set oHybridBody = part1.HybridBodies.Item("Points")
Dim oHBsfactory As HybridShapeFactory
Set oHBsfactory = part1.HybridShapeFactory

End Sub
'=======================

Your help is much appreciated.
Quin
 
Replies continue below

Recommended for you

point on screen is not a catia function (or I do not know anything about it)

if you read scripts in chm file, you should find many exemples creating points.

you can ask user to click somewhere and you can retrieve the HV on the screen using Selection.IndicateOrSelectElement2D or Selection.IndicateOrSelectElement3D, or with win API you can get dynamic cursor position (i think)...

Eric N.
indocti discant et ament meminisse periti
 
Hi All.....so below is the image to illustrate the point that I want to make a VBA macro pick a point on the screen and insert a text string parallel to the screen in a CATPart document.

Is there way to make a VBA macro to achieve this?

POINT_eipvsp.jpg


Thanks for your help
 
also check chm file for Annotation and AnnotationFactory.CreateText

also you check Selection.IndicateOrSelectElementXD in order to give info (after transformation?) to Annotation.SetXY

the script difficulty level would be easy moderate high impossible

post your progress I will help

Eric N.
indocti discant et ament meminisse periti
 
Below it is what I got to this point, creating a 3D point on screen and it could be used for text anchor and text writing later.
--------------------------

'//// Add geometrical Points set and a 3D point to active document
'//// ================================================

Sub ADDPOINT()

'//// Declare 3D ToolBox
Dim my3Dpoint As Factory
Set my3Dpoint = CATIA.ActiveDocument.Part.HybridShapeFactory

'//// Create new Geometrical Set as "points", "lines", "planes", or "curves"...etc
Dim hBridBody As HybridBody
Set hBridBody = CATIA.ActiveDocument.Part.HybridBodies.Add
hBridBody.Name = "Points"

'//// Predefined Geometry. Coordinate points are defined in millimeters
'//// Given coordinate points are converted to inches by CATIA in the tree
Dim myPoint As HybridShapePointCoord
Set myPoint = my3Dpoint.AddNewPointCoord(800, 500, 0)

'//// Assigned Geometry to the Geometrical Set
hBridBody.AppendHybridShape myPoint
CATIA.ActiveDocument.Part.Update '//// Updated geometrical set

End Sub
--------------------
The created 3D point changes its position depending on the view, capture setting, and/or zooming.

I do not know how to get a FIXED coordinate 3D point (at the same spot) on the top-left corner of the screen (right beside the spec tree, so that the text can start at the same spot in each capture for printing out.

Please let me know your thought and advice.
I will look further into Annotation and AnnotationFactory.CreateText as you suggested.

Thanks
 
if you look into the chm file you should find Viewpoint3D object this will help you find the user point of view and from there a point in the top left corner... but again this might not be a direct or easy task.

Be cause you seem to be unfamiliar with scripting and because of what I foresee of what the script might need I suggest you go get some sort of training (VBA or any OO language), then define with business the actual needs (the end result) so if one way to get the result is to difficult, you can switch to the next solution if any. Good programmers are lazy (we call that being smart).

if you want some text on a picture you can place the text then take the picture or you can take the picture and then place the text on it.

it is all about the end result and the easiest way to get there.

that said, I will follow your progress and help you.

Get ready for a long one...

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor