Jump to content
Developer Wiki and Function Reference Links ×

REQUEST: native DTM Nodes


HebHeb

Recommended Posts

Hello there,
it would be nice to have a native node that operates with the DTM.

Input:

  • Site Model (via Location on Layer - handle Input via obj by criteria ?)
  • State of the site model (existing/proposed)
  • x/y-Value

Output:

  • z-Value


btw: I am aware of the possibility right now 😉

https://developer.vectorworks.net/index.php/VS:DTM6_GetZatXY
I don't come from a scripting background, and never feel comfortable (or future proof for version updates) when I create my own nodes...

Cheers!

Edited by HebHeb
Link to comment
  • 2 months later...

Hello,

I somehow can't figure out how i get the "resulting" object when using "VS:DTM6 SendToSurface"

there are some comments on developer.vectorworks.net:

Quote

Ptr [2020.09.14]:When applying this call on a 2D object, that 2D object gets converted into a 3D polygon. The handle to the 2D object will not be linked to this 3D polygon. "vs.LNewObj()" will not return the handle to the 3D polygon.

 

vs.LNewObj() doen't seem to give the handle to the desired result...
i am really no expert in creating my own nodes, so please be patiend ;D

 

...see attched file


maybe @Marissa Farrell can sort this out. the "send to surface" operation seems to work, i just can't get the output handle-

 

@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
	#Name
	this = Marionette.Node( 'Send to DTM Surface' )
	this.SetDescription( 'sends object to DTM Surface' )

	#Input Ports
	hPath = Marionette.PortIn( vs.Handle(0), 'hPath' )
	hPath.SetDescription( 'the input path' )
	hLayer =  Marionette.PortIn( 0 )
	hLayer.SetDescription( 'the layer containing the DTM' )
	iTINType = Marionette.PortIn( 0 )
	iTINType.SetDescription( 'A number identifying the Site Model surface (0 = existing or 1 = proposed)' )
	
	#OIP Controls
	
	#Output Ports
	hPathOUT = Marionette.PortOut('hPathOUT')	
	hPathOUT.SetDescription( "the resultung elevated path" )
	
	#BEHAVIOR
	
def RunNode(self):
	#inputs
	hPath = self.Params.hPath.value
	hLayer = self.Params.hLayer.value
	hDTMObject = vs.DTM6_GetDTMObject(hLayer)
	iTINType = self.Params.iTINType.value

	#script
	vs.DTM6_SendToSurface(hDTMObject, hPath, iTINType)
	### hPathOUT = ###
	
	#outputs
	### self.Params.hPathOUT.value = hPathOUT ###

 

HebHeb_send to DTM Surface.vwx

Edited by HebHeb
Link to comment

In Vectorscript for cases like this where LNewObject does not return the proper object, we use the "Waldo" method (referring to the famous puzzle book, "Where's Waldo")

 

Basically, the method is:

 

Do your operation that creates an object.

Create a loci and get a handle to the loci.

Get the Previous Object handle.

Delete the loci.

 

Not sure how you would make this work in Marionette.

 

image.png.3dc7d5c1c49b88babb0fe99f9154a704.png

  • Like 1
Link to comment

Thanks for your reply.

Now the Python example makes sense ;D
 

_, _sPIOName, _hPIO, _hPIORecord, _hWall = vs.GetCustomObjectInfo()  # Get info from current PIO instance
_hPath = vs.GetCustomObjectPath(_hPIO)
_hDTM = vs.DTM6_GetDTMObject(vs.GetLayer(_hPIO), False)  # Get Site Model on the PIO's layer
_hPoly2D = vs.HDuplicate(_hPath, 0, 0)
_b = vs.DTM6_SendToSurface(_hDTM, _hPoly2D, 0)
vs.Locus(0, 0)  # Create a dummy object
_h = vs.LNewObj()
_hPoly3D = vs.PrevObj(_h)
vs.DelObject(_h)  # Delete the dummy object


I kind of failed like shown above, but with waldo in my mind i'll give it another try 😉
But anyhow, I hope someone can sort it out 
 

Link to comment

FYI. Found a working soloution:

In some cases (i.e. when using a rectangle as path) i had to ungroup twice to get the 3D poly handle.

image.thumb.png.9ac4605e0e0afcdfa64a45863717c2c7.png

 

@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
	#Name
	this = Marionette.Node( 'Send to DTM Surface' )
	this.SetDescription( 'sends object to DTM Surface' )

	#Input Ports
	hPath = Marionette.PortIn( vs.Handle(0), 'hPath' )
	hPath.SetDescription( 'the input path' )
	hLayer =  Marionette.PortIn( 0 )
	hLayer.SetDescription( 'the layer containing the DTM' )
	iTINType = Marionette.PortIn( 0 )
	iTINType.SetDescription( 'A number identifying the Site Model surface (0 = existing or 1 = proposed)' )
	
	#OIP Controls
	
	#Output Ports
	hPathOUT = Marionette.PortOut('hPathOUT')	
	hPathOUT.SetDescription( "the resultung elevated path" )
	
	#BEHAVIOR
	
def RunNode(self):
	#inputs
	hPath = self.Params.hPath.value
	hLayer = self.Params.hLayer.value
	hDTMObject = vs.DTM6_GetDTMObject(hLayer)
	iTINType = self.Params.iTINType.value

	#script
	vs.DTM6_SendToSurface(hDTMObject, hPath, iTINType)
	vs.Locus(0, 0)  # Create a dummy object
	dummy = vs.LNewObj()
	hPathOUT = vs.PrevObj(dummy)
	vs.DelObject(dummy)  # Delete the dummy object
	
	#outputs
	self.Params.hPathOUT.value = hPathOUT

 

Link to comment

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