A scripting example...

I've posted a scripting example called "AF_PointLineGrid.zip," that shows how to use a script to automate the creation of a grid of points, and then how to hook up parameters on those points so that their Z elevation is controlled by a measure point.

 For those of you doing experiments with rectangularly gridded points or deep trusses, this is a good start.

Comments

Renaming Script

I had the same problem.  Try using the "Cstr" (VBA convert to string) command.  So that the entire line reads

param1.name = "pt" + "_" + Cstr(J)

instead of J.Tostring()

"ToString()" reference causing error

Hi Ian,

There's probably a simple thing I'm missing, but while working through this script everything is great until I get to the part where you create the new point name (Point 4 becomes Pt0_4) using:

ptName = "pt" + i.ToString() + "_" + j.ToString()

I get it to work fine using ptName = "some random text", it's just when I add the "ToString()" I get problems. My script below:

 ---------------------------------------------------

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridBodies1 = part1.HybridBodies

Dim parameters, xDist
Set parameters = part1.Parameters
Set xDist = parameters.Item("xDist")
Set yDist = parameters.Item("yDist")

Dim x, y
x = xDist.Value
y = yDist.Value

Set xDim = parameters.Item("xDim")
Set yDim = parameters.Item("yDim")

x_dim = xDim.Value
y_dim = yDim.Value

Set relations = part1.Relations

Set selection1 = partDocument1.Selection
selection1.Clear()

Set analyticalSet = hybridBodies1.Add()
analyticalSet.Name = "ANALYTICAL SET"

Set ptSet = analyticalSet.hybridBodies.Add()
ptSet.Name = "POINTS"
Set lineSet = analyticalSet.hybridBodies.Add()
lineSet.Name = "LINES"

ReDim Preserve ptArr(x_dim, y_dim)

Dim ptName As String

For i=0 To x_dim
  For j=0 To y_dim
    
  ptName = "pt"

Set pt = hybridShapeFactory1.AddNewPointCoord(i, j, 0)
ptSet.AppendHybridShape(pt)
pt.Name=ptName
part1.Update

 

  Next
Next

 

End Sub

 -----------------------------------------------------------

Thanks!

 

EDIT

This Code treats the number as a formula of sorts, so the first point is named 0 (0+0), point2 = 1(0+1), etc. But you can't add any text because then it ceases to be a String.

------------------------------------------

Dim nameX, nameY As String

For i=0 To x_dim
  For j=0 To y_dim
 

 nameX =(i)
 nameY =(j)

Set pt = hybridShapeFactory1.AddNewPointCoord(i, j, 0)
pt.Name = nameX + nameY
ptSet.AppendHybridShape(pt)

part1.Update