VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Block Z value from Civil 3d Surface

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Mikexlt
626 Views, 2 Replies

Block Z value from Civil 3d Surface

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
 

 

2 REPLIES 2
Message 2 of 3
Alfred.NESWADBA
in reply to: Mikexlt

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 -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 3
Mikexlt
in reply to: Alfred.NESWADBA

Thanks Alfred,

 

Works fine now.

 

Mike

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost