Jump to content
Patrick Winkler

Get WS Cell Object Handle

Recommended Posts

Hi Patrick,

 

It looks like you're trying to select a database row, I would suggest looking at functions that start with GetWSSubrowCell.

Let me know if that's not the direction you're going in and I'll take another look.

Share this post


Link to post

Hi Marissa,

 

sorry I could have mentioned that I tried reading the yellow marked cell with GetWSSubrowCell but it returns me nothing.

My goal is to get the handle to the door-row from the worksheet so that I can read data from the ws in write it in a record of

the door.

 

regards

 

Share this post


Link to post

You could possibly use a =RunScript function with a short Vectorscript or Python Script. You can use the WSScript_GetObject command to get the handle to the object that  the subrow is referencing. 

 

I don't think you can get an image out of a cell. The subrow functions only appear to allow you to GET stings or values.

 

The function that I am wishing for is a way to get the cell a RunScript function is in when the script is activated so I can do relative cell references.

 

Let us know if you need more help.

  • Like 1

Share this post


Link to post

Thanks pat.

I needed some attempts to get back from the str to the vs.Handle.

 

The cells get filled with this code:

h = vs.WSScript_GetObject()
h_str = str(h) 
vs.WSScript_SetResStr(h_str)

Then another script iterates trough all objects and compares the handle strings:

 

def get_handle_from_str (h_str):
	h_dict = {} # key: handle_str val: handle

	def collect_handles(h):
		nonlocal h_dict
		h_dict[str(h)] = h 
		
	vs.ForEachObject (collect_handles, 'All')
	
	try:
		h = h_dict [h_str]
	except KeyError:		
		print ('Handle could not be found.')
		h = None
	
	print (h_dict)
	return h

# EXAMPLE
h = get_handle_from_str ('AEC62080')
vs.SetSelect (h)

It's kind of unpracticle and carries the risk if inconsistency but it works.

 

 

ws_test.vwx.zip

Share this post


Link to post

Patrick,

 

I would be careful  with what you are doing. It looks dangerous to me. Also, I think the string you are returning is not the full handle. When I use VectorScript to get the handle as string, I get a different value even after accounting for Python returning the value in Hex and VS in decimal. It appears that Python is leaving off the top 4 hex digits.

 

But let's step back from there.

 

What data do you have in the database row that needs to be written to a record? Since all the data is coming from records already, why do you want to put a copy (with potentially obsolete values) into a record?

 

There is probably a reason, but if you tell us what you are really trying to do and why you think you need to do it we might have a better solution.

Share this post


Link to post

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.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...