VvierA Posted October 18, 2012 Share Posted October 18, 2012 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 Quote Link to comment
Miguel Barrera Posted October 18, 2012 Share Posted October 18, 2012 1. Get the location point of the symbol 2. Use PtInPoly (assuming the space pio is a poly), which will return true if it is within the space boundaries. Quote Link to comment
Hippocode Posted October 24, 2012 Share Posted October 24, 2012 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 ? Quote Link to comment
Dieter @ DWorks Posted October 24, 2012 Share Posted October 24, 2012 (edited) You can use ForEachObject to search for all piping run pio's and then check wich one is on the location of your point pio. this is posible. I've done this before with beams that will look if they are over walls to add things to themself. Edited October 24, 2012 by DWorks Quote Link to comment
Hippocode Posted October 24, 2012 Share Posted October 24, 2012 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 Quote Link to comment
Hippocode Posted October 24, 2012 Share Posted October 24, 2012 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. Quote Link to comment
Dieter @ DWorks Posted October 24, 2012 Share Posted October 24, 2012 The reason why the origin can not be moved by the user!!! Try resetting your origin in the drawing to the Original (= internal origin of vW). Quote Link to comment
MullinRJ Posted October 24, 2012 Share Posted October 24, 2012 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 Quote Link to comment
Hippocode Posted October 25, 2012 Share Posted October 25, 2012 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 Quote Link to comment
Hippocode Posted October 26, 2012 Share Posted October 26, 2012 (edited) 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 October 26, 2012 by hippothamus Quote Link to comment
Dieter @ DWorks Posted October 26, 2012 Share Posted October 26, 2012 (edited) 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 October 26, 2012 by DWorks Quote Link to comment
Hippocode Posted October 26, 2012 Share Posted October 26, 2012 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); Quote Link to comment
Recommended Posts
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.