I can't quite get this to work.
I am placing blocks onto a civil 3d surface and running the following code to set the Z valve of the Block from the surface. I can get the elev value, but can't get to assign it to the z value for the block. What am i missing?
For Each NodeEnt In SelNode Set node = SelNode.Item(i) nodex = NodeEnt.InsertionPoint(0) nodeY = NodeEnt.InsertionPoint(1) elev = surf.FindElevationAtXY(nodex, nodeY) NodeEnt.InsertionPoint(2) = elev NodeEnt.Update If elev = 0 Then ' MsgBox "Node " & "N" & N & " at X= " & Format(nodeX, "0.00") & " Y=" & Format(nodeY, "0.00") & vbCrLf & " has no elevation" Error.TextBox1.Text = Error.TextBox1.Text & "Node " & "N" & n & " at X= " & nodex & " Y=" & nodeY & " has no elevation" & vbCrLf ERRSTATUS = 1 End If ' NodeEnt.GetXData "mdc_Hyd", 1070, xdata 'elevation = elev + NodeDepth elevation = elev Epanet.TextBox4.Text = vbCrLf & Epanet.TextBox4.Text & "N" & n & vbTab & elevation & vbCrLf 'i = i + 1 n = n + 1 Next NodeEnt
Solved! Go to Solution.
Solved by Alfred.NESWADBA. Go to Solution.
Hi,
you can't just modify the array item at index 2 of the object's insertion point.
Create a new variable with 3 doubles, assign them x/y/new z and assign that variable to the insertion point of the blockreference:
Dim tNewPnt(2) as double
'get the x/y/new z values
tNewPnt(0) = NodeEnt.InsertionPoint(0)
tNewPnt(1) = NodeEnt.InsertionPoint(1)
tNewPnt(2) = surf.FindElevationAtXY(tNewPnt(0), tNewPnt(1))
'assign that new point to the blockref's insertion point
NodeEnt..InsertionPoint = tNewPnt
Not tried, just out of remembering, hopefully that remembering works ok 😉
- alfred -