Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Measure Distance - Point to Surface 1

Status
Not open for further replies.

Ian Cuz

Aerospace
Dec 6, 2017
18
Further to my recent post - refer to "thread560-433573"

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 :)

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, 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
 
 http://files.engineering.com/getfile.aspx?folder=6450d5fc-b0b9-4e7e-88af-c57266555ff6&file=Create_Distance_Measure-Surface-Point_RECORDED.catvbs
Replies continue below

Recommended for you

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
 
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

:)

 
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#)
 
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
 
 http://files.engineering.com/getfile.aspx?folder=efeab9fc-a101-4205-8600-107e8faa7159&file=Capture.JPG
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor