×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

macro to project 3d point to sktech

macro to project 3d point to sktech

macro to project 3d point to sktech

(OP)
I have 3d point and wanted to project it on to sketch with face support. I wanted to find the coorindates of the projected point

Here is the macro I am using but getting error as

GetCoordinates not support by the object

Language="VBSCRIPT"

Sub CATMain()

Dim partDocument1 As Document

Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part

Set part1 = partDocument1.Part

Dim bodies1 As Bodies

Set bodies1 = part1.Bodies

Dim body1 As Body

Set body1 = bodies1.Item("PartBody")

Dim sketches1 As Sketches

Set sketches1 = body1.Sketches

Dim reference1 As Reference

'Set reference1 = part1.CreateReferenceFromName("Selection_RSur:(Face:(Brp:(Pa d.1;1);None:();Cf11:());Pad.1_ResultOUT;Z0;G3055)")

@

Dim InputObjectType(0)

InputObjectType(0)="Face"

'Dim reference1 As Reference

Dim oStatus As Status

Dim oSelection

Set Document = CATIA.ActiveDocument

Set oSelection = CATIA.ActiveDocument.Selection

oStatus = oSelection.SelectElement2 ( InputObjectType, "Select face for sketch referance", True )

Dim face

Set face= oSelection.Item(1).value

Dim sketch1 As Sketch

Set sketch1 = sketches1.Add(face)

Dim arrayOfVariantOfDouble1(8)

arrayOfVariantOfDouble1(0) = 0.000000

arrayOfVariantOfDouble1(1) = 0.000000

arrayOfVariantOfDouble1(2) = 0.000000

arrayOfVariantOfDouble1(3) = 1.000000

arrayOfVariantOfDouble1(4) = 0.000000

arrayOfVariantOfDouble1(5) = 0.000000

arrayOfVariantOfDouble1(6) = 0.000000

arrayOfVariantOfDouble1(7) = 1.000000

arrayOfVariantOfDouble1(8) = 0.000000

sketch1.SetAbsoluteAxisData arrayOfVariantOfDouble1

part1.InWorkObject = sketch1

Dim factory2D1 As Factory2D

Set factory2D1 = sketch1.OpenEdition()

Dim geometricElements1 As GeometricElements

Set geometricElements1 = sketch1.GeometricElements

Dim axis2D1 As GeometricElement

Set axis2D1 = geometricElements1.Item("AbsoluteAxis")

Dim line2D1 As CATBaseDispatch

Set line2D1 = axis2D1.GetItem("HDirection")

line2D1.ReportName = 1

Dim line2D2 As CATBaseDispatch

Set line2D2 = axis2D1.GetItem("VDirection")

line2D2.ReportName = 2

Dim hybridShapes1 As HybridShapes

Set hybridShapes1 = body1.HybridShapes

Dim reference2 As HybridShape

'Set reference2 = hybridShapes1.Item("Point.1")

Dim InputObjectType2(0)

InputObjectType2(0)="Point"

Dim oStatus1 As Status

Dim oSelection2

Set Document = CATIA.ActiveDocument

Set oSelection2 = CATIA.ActiveDocument.Selection

oStatus1 = oSelection2.SelectElement2 ( InputObjectType2, "Select 3D Point", True )

Dim Point

Set Point = oSelection.Item(1).value

@

Dim geometricElements2 As GeometricElements

Set geometricElements2 = factory2D1.CreateProjections(Point)

Dim pt As Point2D

set pt = geometricElements2.Item(1)

Dim arrayOfVariantOfDouble2(2)

Pt.GetCoordinates(arrayOfVariantOfDouble2)

MsgBox(arrayOfVariantOfDouble2(0))

MsgBox(arrayOfVariantOfDouble2(1))

@

@

sketch1.CloseEdition

part1.InWorkObject = sketch1

part1.Update

End Sub



Thanks

Shiva



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources