Jump to content

Snap object to TIN surface


VictorC

Recommended Posts

Hello everyone,

 

I hope I can get some help on this the following.

 

I have a TIN surface that was created from topography points. I have multiple trees which are placed on different parts of the x-y plane of the TIN surface (z-plane is elevation). I need the base of the trees to align to the z-axis of the TIN surface at the location the tree is. Currently the trees are at the same z-axis coordinate. Is there a command in AutoCAD that lets me select the trees and snap them to the TIN surface?

 

Attached is an example of the main file I'm dealing with. TIN surface is in LG_TOPO and trees are in LG_TREES.

 

Thank you very much for the help!

example.dwg

Link to comment
Share on other sites

So all trees are at say z=0 is that what your saying ?

 

Ok good news and bad news if you have CIV3D there is a built in option to get a XYZ point on a TIN. 

 

Ok there is a formula for a 3D point given XY on a 3dface. Ie 3 point plane. There is some free TIN software out there but I don't know if it does a point. You may need to copy the tin and explode it then can get a point on a 3DFACE. But have to Google for the code.

 

Just a question did you add the trees so they were not field surveyed. 

 

 

 

 

 

Link to comment
Share on other sites

See this page. If you can load a TIN surface, you should have access to Civil 3D commands. On the Surface menu, pull down the Utilities. There's a command to Move Blocks to Surface.

 

If you're using some other flavor of AutoCAD, take BigAl's advice and find some code to do the same thing.

Link to comment
Share on other sites

If you used Google you may find this,

 

Have a look at the GP code but note needs 3dfaces not a TIN. 

 

Link to comment
Share on other sites

If there’s not command, you can do this with the API. Here’s a sample in Python. check the drawing and make sure it's correct : )

 

import traceback
from pyrx_imp import Rx
from pyrx_imp import Ge
from pyrx_imp import Gi
from pyrx_imp import Gs
from pyrx_imp import Db
from pyrx_imp import Ap
from pyrx_imp import Ed
from pyrx_imp import Cv

# debug
def PyRxCmd_pydebug() -> None:
    import PyRxDebug
    PyRxDebug.startListener()

def PyRxCmd_doit() -> None:
    try:
        db = Db.curDb()
        esel = Ed.Editor.entSel("\nSelect TIN Surface: ", Cv.CvDbTinSurface.desc())
        if esel[0] != Ed.PromptStatus.eOk:
            print("Oops {}: ".format(esel[0]))
            return

        filter = [(0, "INSERT"), (2, "Simple Tree")]
        ssres = Ed.Editor.selectAll(filter)
        if ssres[0] != Ed.PromptStatus.eOk:
            print("Oops {}: ".format(ssres[0]))
            return
        
        pSurface = Cv.CvDbTinSurface(esel[1])

        for id in ssres[1].objectIds():
            ref = Db.BlockReference(id, Db.OpenMode.kForWrite)
            sp = ref.position()
            ep = sp + Ge.Vector3d.kZAxis * pSurface.maxElevation()
            line = Db.Line(sp,ep)
            pnts = pSurface.intersectWith(line,Db.Intersect.kExtendArg)
            if len(pnts):
                ref.setPosition(pnts[0])
        
    except Exception as err:
        traceback.print_exception(err)

 

move.png.e08ea79ede9720d3527e6da5f1ec34a7.pngexample.dwg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...