Assembly Posted November 19, 2009 Share Posted November 19, 2009 I'm trying to make a function that works like Hduplicate but for 3D. This is how I think it will work. FUNCTION hDuplicate3D(copyhandle:handle;xoffset,yoffset,zoffset:real):Handle; BEGIN; Copyhandle:=HDuplicate(copyhandle,0,0); Move3DObj(copyhandle,xoffset,yoffset,zoffset); END; How do I get the function to return the handle of the new object?. I want to be able to use in a repeat statement IE REPEAT n:=n+1; Myobjecthandle:=hDuplicate3D(myobjecthandle,0,0,Zspace); UNTIL (N=10) Quote Link to comment
mike m oz Posted November 20, 2009 Share Posted November 20, 2009 Why reinvent the wheel? Duplicate Array under the Edit menu has a Z option in all three modes: Linear, Rectangular and Circular. There are also rotate and resize object options for all three modes and the Linear Array has Cartesian and Polar methods. Quote Link to comment
Assembly Posted November 20, 2009 Author Share Posted November 20, 2009 DoMenuTextbyName is not advisable inside PIO. Quote Link to comment
ccroft Posted November 20, 2009 Share Posted November 20, 2009 Try putting this as the last line of the function declaration, before 'END' hDuplicate3D := CopyHandle; Not obvious at first, but makes sense if you think about it. You want the compiler to see hDuplicate3D as the return value of your function, which in this case is copyhandle. A function is kinda like a self-assigning variable. It is because of this characteristic that you can use a function directly without assigning it's return value to another variable, should you so desire. Quote Link to comment
Assembly Posted November 20, 2009 Author Share Posted November 20, 2009 Thanks Charles Works as you say. Quote Link to comment
MullinRJ Posted November 20, 2009 Share Posted November 20, 2009 Hi Justin, ???If you are going to create multiple copies and want to get at their handles after your repeat loop executes, you'll probably want to save them as you create them. Try something like this: VAR ???HArray = DynArray [ ] of Handle; ... Cnt := 10; Allocate HArray[0..Cnt]; n := 0; HArray[n] := MyObjectHandle;???{ element 0 holds handle to original } REPEAT ???n := n + 1; ???HArray[n] := hDuplicate3D(HArray[n-1], 0, 0, Zspace); UNTIL (n = Cnt); Raymond Quote Link to comment
Assembly Posted November 20, 2009 Author Share Posted November 20, 2009 while not required for todays script, i know where i can use that- thanks 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.