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!

macro to project 3d point to sktech

Status
Not open for further replies.

enggshiva

Mechanical
Jan 1, 2013
1
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



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor