×
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

Measure Distance - Point to Surface

Measure Distance - Point to Surface

Measure Distance - Point to Surface

(OP)
Further to my recent post - refer to "thread560-433573: Measuring Area of a Fill Surface"

I wish to avoid using SPAWorkBench to return a Distance Measure Value
I also wish to create a loop whereby I Measure between a Surface and a number of Points sequencially
I recorded the manual method and altered it as per the advise in the thread above but it
does not create the Formula Relation correctly

Can anyone please advise - thanks smile

My test code below and attached:-

Language="VBSCRIPT"

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set parameters1 = part1.Parameters

Set length1 = parameters1.CreateDimension("DIST_PARAMETER", "LENGTH", 0.000000)

Set relations1 = part1.Relations

' Recorded Create Formula code line
'Set formula1 = relations1.CreateFormula("FORMULA", "", length1, "distance(`Surfaces\Sweep-ISOLATED` ,Points1\Point.1 ) ")

'* To put this functionality into a Loop, I need to pass different objects into the CreateFormula method
'* Further to Forum Thread = thread560-433573: Measuring Area of a Fill Surface, I have built a String to represent the Object Name (including Parent GeoSet)

strSurfaceObjectName = "Surfaces\Sweep-ISOLATED"

'* Test Message
' MsgBox "Surface Name = " & strSurfaceObjectName

strPointObjectName = "Points1\Point.1"

'* Test Message
' MsgBox "Point Name = " & strPointObjectName

' Create Formula Using A Manually Built String - As Per Advise For AREA Measurement
Set formula1 = relations1.CreateFormula("Dist_Formula", "", length1, "distance( " & strSurfaceObjectName & ", " & strPointObjectName & ") ")

'* Test Message
MsgBox "Distance Measure Value = " & length1.Value

part1.Update

End Sub

RE: Measure Distance - Point to Surface

distance(`Surfaces\Sweep-ISOLATED` , `Points1\Point.1` ) is what you want
distance(Surfaces\Sweep-ISOLATED, Points1\Point.1 ) is what you use

You should use `and not ' <- I think that your mistake is here

try to build the complete string before like

myMeasureString = "distance( `" & strSurfaceObjectName & "`, " `& strPointObjectName & "` ) "

then use it in formula

Set formula1 = relations1.CreateFormula("Dist_Formula", "", length1, myMeasureString )

Eric N.
indocti discant et ament meminisse periti

RE: Measure Distance - Point to Surface

(OP)
Thank you once again ItsMyJob your suggestion has steered me to a solution that works

A strange observation I have made is that the GeoSet and Point string can be passed as a pure string
Whereas the GeoSet and Surface seems to need the " ` " (forward quote) symbol building into the string
for it to function within the CreateFormula code - odd !!!

To make my Distance Measure Function available for any object to any object usage in the future I shall
a specific note regarding the need for the quote character in some circumstances

smile

RE: Measure Distance - Point to Surface

Hi,
i am using this code.
But due to some reason i m getting only 0 in as measure.

Dim length1 As Dimension
Set length1 = parameters1.CreateDimension("", "LENGTH", 0#)

RE: Measure Distance - Point to Surface

(OP)
Hi All

With the help above I managed to manually construct the necessary Strings to create the distance formula
I am now attempting to integrate this technique into larger "existing" macro that asks for a User Selection
of Surface to be used as the Primary Measure Object - a loop provides a means to measure a number of Points
back to this Surface

I have now have a NEW problem with constructing the String for the formula function when using a
"Isolated Surface Object" as the User Selection.

I have been using the following expression to build the String
strSurface_FunctionInputString = "`" & Surface.Parent.Parent.Name & "\" & Surface.Name & "`"

This works exactly as required for Non Isolated Surface Objects - But not for Isolated ones

I have also included a picture of my test model Spec Tree and the MsgBox returns for the Non Isolated
and Isolated Surfaces as built by the above code line

Any ideas how I can return the actual parent GeoSet of where the Isolated Surface is structured ?

Many thanks in advance

RE: Measure Distance - Point to Surface

well isolated surface are not regular geometry.
If you select it you can get the full path using CATIA.Statusbar information.
Or you can check each oPart.Hybridbodies to see if your surface is in it.

you call

Eric N.
indocti discant et ament meminisse periti

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


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close