Jump to content

Get WS Cell Object Handle


Recommended Posts

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
Link to comment

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

Link to comment

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.

Link to comment
  • 3 years later...

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