Jump to content
Developer Wiki and Function Reference Links ×

Is there a way to check, if a graphic element lies on top of something?


VvierA

Recommended Posts

Hello,

with the fantastic help of the members of this forum I managed to program a custom made space tool for my special needs.

Now I am wondering, if there is a way to do the following...

Is it possible to check, if an element (for example the symbol of a table) is sitting on top of my space polygon?

If so - I could automatically list the symbols with the information in which room the table is located.

Any ideas?

Kind regards

VvierA

Link to comment

What if there is no poly to work with ?

I've got a point PIO object which will be placed on a piping run. The idea is, that it will take over the settings/data from that pipeline, aslong as I place it somewhere on the pipeline. Thus the question is how to get a handle to that pipeline.

I tried selecting that pipeline first before adding the new point PIO, but ForEahObjectInLayer doesn't seem to return much in my point PIO.

Any suggestions ?

Link to comment

I've tried your suggestion but fail at getting the right insertion point of the point PIO.

I guess that's the same problem I'm having in the following script: http://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=178052Post178052

Back to this one:

GetSymLoc returns me:-137060,-348297.79

GetOrigin returns me:-955,1003

hovering over the insertion point of the point PIO gives me:12750,35833

I've read this page but I just don't know what to do next, lol.

http://www.vectorlab.info/index.php?title=Absolute_Origin

Link to comment

update:

I managed to get the relationship between the values.

If I do the following calculation, the numbers match !

(Getsymloc/10)+Getorigin= insertionpoint on hover.

Since a factor 10 is involved I think about units. at this point i'm using cm.

Changing them to mm gives the following:

(Getorigin values raise factor 10 it seems)

Getsymloc+getorigin= insertionpoint.

Well that sucks. This means that the getsymlocation always returns in mm, while getorigin returns in the units from the settings.

Link to comment
Well that sucks. This means that the getsymlocation always returns in mm, while getorigin returns in the units from the settings.

GetSymLoc(); returns document units, at least in every program I've ever written. I'm not sure why your numbers are off by a scale factor of 10. I think you'll need to look elsewhere.

Some functions do return mm only. For those that do, you can scale them to document units with:

Val_In_Doc_Units := Val_In_mm * GetPrefReal(152) / 25.4;

Raymond

Link to comment

Allright,

Opened a new document, created a speaceobject, placed 2 symbols in it to test my script.

The script will return a dialog for each symbol it can find within the poly path of the vw space object.

The weird thing is, it works, but only for symbols placed at the bottom or under the space object.

I believe that the loaded path gets shifted down for some reason. Enlighten me ?:(

The file(vw2010) is added to this post, including the script

Link to comment

Well, I tested my assumptions with a rectangle ( see added picture to this post ).

The weird thing is, that the script gets the path found in the rectangle. The rectangle has the same size as the path, but starts in the middle of the path with its top left boxpoint.

Wherever I move the symbols within the rectangle, it will get found as if it is in the spaceobject !

Now my guess is, that If i substract(y) and add(x) half of the space bounding box to each coordinate of the symbol, the script would work. But I'm looking for an explanation why its off :/

In the space PIO info tab, the point x,y is also placed on -250,250 instead of 0,0 while in the drawing its centerpoint it at 0,0. This is also returned by getsimloc(spaceobject).

I Guess I found it ;)

Edited by hippothamus
Link to comment

GetCustomObjectPath will give you the path relative to the pio insertion point, that's the reason your script isn't working well. You will have to calculate the position of the symbols to match the origin of the pio. So in your script, the co?rdinates of the poly (space) are from the origin of the poly, while your symbols are from the origin of the drawing. So you need to do some math to get these origins on top of each other.

Edited by DWorks
Link to comment

Yeah I finaly get it :)

This is the working script:

Procedure FindSymbols;
VAR
SpaceHandle,PolyHandle: 	HANDLE;
i,j:					INTEGER;
temp_string:				STRING;
originPt:				POINT;
Procedure GetSpace(ObjHandle:HANDLE);
VAR
	Temp:INTEGER;

FUNCTION GetSymbols(SymHandle:HANDLE) :BOOLEAN;
VAR
	symPt:			POINT;
	SymbolName:		STRING;
BEGIN
	GetSymLoc(SymHandle,symPt.x,symPt.y);
	SymbolName:=GetSymName(SymHandle);
	IF PtInPoly(symPt.x-originPt.x,symPt.y-originPt.y,PolyHandle) AND (SymbolName <>'') THEN BEGIN
		AlrtDialog(concat(SymbolName,' IS FOUND IN ',GetName(ObjHandle),' ON : x=',symPt.x,' y=',symPt.y));
		{ we found the symbol in the spaceobject }
	END;
END;
BEGIN
	SpaceHandle:=ObjHandle;
	{ Get the space insertion point to correct the coordinates }
	GetSymLoc(ObjHandle,originPt.x, originPt.y);
	{ space found }
	IF SpaceHandle <> NIL THEN BEGIN
		{ Get the path }
		PolyHandle:=GetCustomObjectPath(SpaceHandle);

		{ Only get all the objects in the current layer }
		ForEachObjectInLayer(GetSymbols,0,2,0);
	END;
END;
BEGIN
{ Loop trough each custom space object }
ForEachObject(GetSpace,((PON='Space')));
END;
Run(FindSymbols);

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