Automation

Frequently Asked Questions About Automation

Quick Reference

Abstract

The questions below come either from CAA partners or customers, or from the Dassault Systèmes group.


Why can't I get the coordinates of my point?

First beware to the syntax:

Redim aCoord(2)
oPoint.GetCoordinates aCoord
Then, if the point has just been created, as the coordinates are the result of the evaluation of the point, they might not be available so compute it first either directly using the Compute method or using Part::Update:
Set oPoint = oHSFactory.AddNewPointOnCurveFromPercent (...) 
oHBody1.AppendHybridShape oPoint
oPart.InWorkObject = oPoint

oPart.Update                     ' --> MANDATORY TO HAVE COORDINATES
oPoint.GetCoordinates coord1     ' --> OK now ...

[Top]

How do I access CATIA V5 from Excel?

Use the GetObject or CreateObject global functions. For more details, look in Invoking CATIA from a Scripting Language.

Dim CATIA As Object
Set CATIA = GetObject (, "CATIA.Application") ' has to be running
MsgBox CATIA.ActiveDocument.Name 

[Top]

How do I know to which document belongs a product?

It's the parent of the reference product:

' Print the name of the documebt containing my product
MsgBox myProduct.ReferenceProduct.Parent.Name

[Top]

How do I know which subproducts of a product are parts?

Fetch the document to which the product belongs and test its type.

[Top]

How to delete objects?

Except when directly available in the aggregating collection, you generally have to put it in the selection (it has to be part of the active document) and use the Selection::Delete method:

Dim oSel As Selection
Set oSel = CATIA.ActiveDocument.Selection

oSel.Clear
oSel.Add(myElement)
oSel.Delete

[Top]

How do I modify the extremity point of an HybridShape line?

Get a reference from the target Point and use it to valuate the Origin property of the Line

[Top]

My Macro that creates Components does not works any more from V5R4

Reference products are nom clearly identified as such. The Products::AddComponent methods now needs a reference product that can be obtained from a Product using its ReferenceProduct property:

dim refProduct As Product
set refProduct=Funnel1.ReferenceProduct 

Dim Funnel2 As Product 
Set Funnel2 = TitanicProducts.AddComponent(refProduct)

History

Version: 1 [Dec 2001] Document created
[Top]

Copyright © 2001, Dassault Systèmes. All rights reserved.