Jump to content
Developer Wiki and Function Reference Links ×

Marionette Mark all objects on a specific coordinate


C.Wittmann

Recommended Posts

Hello, I'm looking for a way to activate all objects that are on a certain coordinate with marionette without activating the adjacent objects. It doesn't matter whether the coordinate is VectorWorks 0;0 or georeferenced.
I've already experimented with objbycrit, there you can choose an object in Place, which marks all things inside or outside of this object. But it doesn't work as desired, since it only marks the objects that are also fully within the object. I need something more like the selection when you draw a rectangle and hold down the command key. Or just everything that lies on a certain coordinate point. Does anyone know what or have the code for it?

Link to comment

Hello,

 

i think there is a function you can use for this. You can read about the function here:

https://developer.vectorworks.net/index.php/VS:FindObjAtPt_Create

 

I use this in one of my scripts, but i never tried using it within a marionette network. However you can put this function into a marionette node. Such a node could look something like this (to create the node, please replace the code in a node with the code below and click ok):


@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
	#Name
	this = Marionette.Node( 'get_objects_at_point' )
	this.SetDescription( 'get_objects_at_point' )

	#Input Ports
	point_in = Marionette.PortIn( (0, 0), 'point' )
	point_in.SetDescription( "point" )

	#OIP Controls
	object_options_input = Marionette.OIPControl( 'object options', Marionette.WidgetType.Popup, 0, ['All objects', 'Visible only', 'Selected only', 'Unlocked only'])
	object_options_input.SetDescription('object options')
	
	travers_options_input = Marionette.OIPControl( 'travers options', Marionette.WidgetType.Popup, 0, ['Shallow', 'Groups'])
	travers_options_input.SetDescription('travers options')
	
	pick_radius_input = Marionette.OIPControl( 'rick radius', Marionette.WidgetType.Real, 0.1)
	pick_radius_input.SetDescription('rick radius')

	#Output Ports
	objects_out = Marionette.PortOut('objects')   
	objects_out.SetDescription( "objects" )

#BEHAVIOR

	
def RunNode(self):
	#inputs
	point = self.Params.point_in.value
	object_options = self.Params.object_options_input.value
	travers_options = self.Params.travers_options_input.value
	pick_radius = self.Params.pick_radius_input.value
	
	# FUNCTIONS
	def get_objects_at_point(object_options, travers_options, point, pick_radius):
		object_finder_id = vs.FindObjAtPt_Create(vs.Handle(0), object_options, travers_options, point[0], point[1], pick_radius)

		objects_at_point = []
		for i in range(vs.FindObjAtPt_GetCount(object_finder_id)):
			objects_at_point.append(vs.FindObjAtPt_GetObj(object_finder_id, i))

		vs.FindObjAtPt_Delete(object_finder_id)
		return(objects_at_point)


	#script
	

	#outputs
	self.Params.objects_out.value = get_objects_at_point(object_options, travers_options, point, pick_radius)

 

This node gives you a list of all objects at a specific point.

 

Please note that it is possible that some settings/arguments do not make sense if this function is run within a marionette network even if i included them into the node (for example the setting/argument "selected only").

 

 

Regards,

Letti

Link to comment

I don't think there is a way to automatically select objects that are "touched" by a shape the way the marquee mode of the selection tool with the option key does.

 

The Vectorscript and worksheet criteria to get a object by Location usually only works for objects when the geometric "center" of the bounding box is inside the location.

 

If I had to script this I would probably check each object and make a list of all the objects that had a corner of their bounding box inside the area. Then I would do different types of checks for different object types. For polys I would check for a vertex that is inside the area. But this might not be enough as you could have an edge that passed through the area by the vertices on each end of the edge could be outside of the area.  It gets even trickier for curves.

 

Letti's idea of objects at point plus a radius may be the best option.

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