GioPet Posted November 27, 2015 Share Posted November 27, 2015 When using files created with an older version of Vectorworks (or from an old template file) I have come across this problem: - if I use HCenter to get the coordinates of a handle, then create a rectangle in that point using RectangleN, the function doesn't work at all. - The coordinate values in the old drawing have 4digits before decimal point and 10 digits after. If I copy and paste in place the same rectangle into a new document, the coordinates in the new documents have 5 digits and no decimal point at all. The Document Settings and Unit settings of the two files are identical.. so there seems to be a problem with the X and Y values of points in the drawing space of old drawings. Does anybody know anything about this behaviour and how to resolve this problem?? thanks for any suggestion G Quote Link to comment
Hippocode Posted November 27, 2015 Share Posted November 27, 2015 (edited) Just to be sure both documents have the same version right ? If for whatever reason the number of stored digits changed, can't you just "reset" all objects prior to copying them over ? If that doesn't help I can only assume the data is lost while copying. Edited November 27, 2015 by Hippocode Quote Link to comment
GioPet Posted November 27, 2015 Author Share Posted November 27, 2015 Yes, the two documents are saved with the same version, but one is newly created and the other has been converted from a Vectorworks 2009/2010. I tried the following to rest all objects and their bounding box, but the issue still remains: PROCEDURE RESETIT; FUNCTION ForAll(Hnd: HANDLE) :BOOLEAN; BEGIN SetSelect(Hnd); ResetObject(Hnd); ResetBBox(Hnd); END; { ForAll } BEGIN DSelectObj(All); ForEachObjectInLayer(ForAll, 0, 2, 1); END; RUN(RESETIT); Rather than the issue with copying objects between two documents, my main problem is that the function RectangleN is not capable of creating a rectangle when I use HCenter to get the coordinates of an existing object in the document which I want for the insertion point for the new rectangle. Quote Link to comment
GioPet Posted November 28, 2015 Author Share Posted November 28, 2015 I tried centering the drawing on the Internal Origin and setting the User Origin to the Internal Origin. Unfortunately it did not resolve the problem.. Quote Link to comment
Hippocode Posted November 28, 2015 Share Posted November 28, 2015 Try SymLoc instead to get the insertion point. HCenter just gives the center of the bounding box. Quote Link to comment
GioPet Posted November 28, 2015 Author Share Posted November 28, 2015 (edited) I can't find SymLoc in the vectorscript functions reference.. on the other hand, I need to read the center of the bounding box because that's where I want a new rectangle to be created (then move/edit it from there through other functions). doing some more testing, I realised that the function that is not 'working' properly is LObject (to get the handle of the last object created) - it returns a point with crazy coordinates, therefore I get the problem getting HCenter for the last created object.. Exactly the same code works 100% fine with drawings that have been newly created with Vectorworks 2016.. Edited November 28, 2015 by GioPet Quote Link to comment
Dieter @ DWorks Posted November 28, 2015 Share Posted November 28, 2015 LObject isn't for the last object that was created: Function LObject returns a handle to the last object in the first layer of the active document. Use LNewObj, which is exactly to get the last created object: Returns a handle to the last object created by a VectorScript function call during the current script execution. Quote Link to comment
Dieter @ DWorks Posted November 28, 2015 Share Posted November 28, 2015 (edited) @GioPet: I'm very interested in what's not working and want to find out together what needs to be done to get it to work. I would love to add it to DLibrary once we have the solution. It's what DLibrary is for: wrapping VS and avoid all weird stuff in it, making it easier to work with objects etc... Edited November 28, 2015 by Dieter @ DWorks Quote Link to comment
GioPet Posted November 28, 2015 Author Share Posted November 28, 2015 Thanks for jumping in Dieter! I just realised that the LObject definition is different between function reference VW2015 and VW2016 .. I was obviously looking at the old one.. I understand now why my code with LObject makes the script work when there is only one Layer in the document.. so, I have replaced LObject with LNewObj, which works for the parts of my code where objects are created by vectorscript. My script starts with a call to the rectangle tool - CallTool(-203) - then i need to get the handle to the rectangle created by the user, which LSactLayer does correclty. 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.