Jump to content

MullinRJ

Member
  • Posts

    1,987
  • Joined

  • Last visited

Posts posted by MullinRJ

  1. Thanks, Patric,

    It's never as easy as it first seems. You obviously like puzzles, so, over time it will get easier. One of the joys of programming in VW is that you are manipulating images, so you can see the results of your efforts as you work, and sometimes the mistakes are more beautiful than the desired results - sometimes. I'm glad you're enjoying it.

    Petri,

    At times, I've used the indirect method for sorting arrays. I've not tested this, but for large arrays with a lot of data in each cell (as with a large structure), I wonder if the indirect method might be faster. If I ever figure it out, I'll let you know.

    Raymond

  2. Hi Petri,

    ???You almost had it. With a few minor changes it now works.

    Raymond

    PROCEDURE CentrePoints;

    VAR

    ???obHd : HANDLE;

    ???clockWise : BOOLEAN;

    ???t : INTEGER;

    ???x, y, dx, dy, a, aR, a1, a2, r, d, l : REAL;

    ???x1, y1, x2, y2, x3, y3 : REAL;???{ added these to make it compile }

    ???v1, v2 : VECTOR;

    BEGIN

    ???obHd := FSACTLAYER;

    ???GETPOLYPT(obHd, 1, x1, y1);

    ???GETPOLYLINEVERTEX(obHd, 2, x2, y2, t, r);

    ???GETPOLYPT(obHd, 3, x3, y3);

    ???

    ???v1.x := x1-x2; v1.y := y1-y2;??????{ make vector v1 point away from point 2 }

    ???v2.x := x3-x2; v2.y := y3-y2;??????{ yes, points away from point 2 }

    ???a1 := VEC2ANG(v1);

    {??a2 := VEC2ANG(v2);}????????????????{ don't need this anymore }

    ???a := ANGBVEC(v1, v2)/2;??????????{ remove 180 from calculation, as v1 is now reversed }

    ???aR := TAN(DEG2RAD(a));

    ???d := r/aR;

    ???l := SQRT(r^2+d^2);

    ???

    ???{ use clockWise condition to add or subtract angle a to/from angle a1 }

    ???clockWise := GETOBJECTVARIABLEBOOLEAN(obHd, 652);

    ???if clockWise then a := DEG2RAD(a1+a)

    ???else a := DEG2RAD(a1-a);

    ???

    ???dx := l*COS(a);

    ???dy := l*SIN(a);

    ???LOCUS(x2+dx, y2+dy);

    END;

    RUN(CentrePoints);

  3. Hi Patric,

    ???I think you should see your negative coordinate problem go away. One of the problems you were having was that you were swapping elements in the handle array, but not in the pX & pY arrays. You also needed to swap the same components in the pX and pY arrays when you swapped a handle in the H array if you wanted the handles and associated coordinates kept together.

    ???With an array of structures, you will be swapping whole structures from one position to another, guaranteeing that the X and Y travel with the H. This is why I proposed building the structure this way. Less things to go wrong when you finally get around to sorting the data the way you want.

    Raymond

  4. Patric, I think if you simplify your data structure, it will be a lot easier to manipulate the elements.

    Start by defining a "Structure" that you'll store in an array. It should contain a handle and a point.

    TYPE

    ???SymbolPositions = Structure

    ??????H :Handle;

    ??????P :Point;??????{ also a structure (predefined) }

    ???end;??????{ SymbolPositions }

    Now create an array to hold these elements.

    VAR

    ???SymPosArray :Dynarray [] of SymbolPositions;

    ???

    It is not yet dimentioned, because you don't know how many elements you will put into it. This you will figure out at runtime.

    You may also need to create a variable of the same type as your structure that you can hold one array element in.

    ???SymPos : SymbolPositions;

    Next, in your main program, you need to count how many objects you want to collect data on. There are many ways to do it. I'll leave it to you to find the best way as I don't know how your drawing is structured. Often, you will select all items of interest then run you program against the selected objects, but that's only one way.

    When you have the count, CNT, you ALLOCATE your array size. The array is linear, as each element is a Structured variable, but each element has two parts, actually three because the second element of your structure, P, is also a structure of TYPE Point, where P has two parts, P.x and P.y.

    To access an element in your array, you can say:

    ???SymPos := SymPosArray[7];??????{ data stored in array position 7 - H and P}

    ???

    To access the pieces of your structure, say:

    ???SymHnd := SymPos.H;???????????????{ from a single variable }

    ???SymHnd := SymPosArray[7].H; ??{ from an array of structures }

    Since the point data in your structure is also a structure, acess it like this:

    ???SymX := SymPosArray[7].P.x;

    ???SymY := SymPosArray[7].P.y;

    ???

    This may be a lot for starters, but it is much easier to modify your code if your variables are built in a way that makes the code easier to manipulate. KISS is my guiding light. Now, back to the big picture...

    Your main program will have a format somewhat like this:

    BEGIN

    ???{ Count your symbols }

    ???CNT := { some function to count them }

    ???Allocate SymPosArray [1..CNT];

    ???{ Read your handles and XY values into the array }

    ???SymHnd := { Get your first handle }

    ???for I := 1 to CNT do begin

    ??????SymPosArray.H := SymHnd;

    ??????GetSymLoc(SymHnd, SymPosArray.P.x, SymPosArray.P.y);

    ??????SymHnd := { Get your next handle, usually with NextSObj(SymHnd); }

    ???end;

    ???{ Now you can sort }

    ???{ I would try the VS command SortArray() here, but you may have to do it manually. }

    ???{ To sort on both X & Y variables, you need to sort your primary variable last. }

    ???{ The rest of your program... }

    END;

    Have fun,

    Raymond

  5. Hi Michael,

    ???Yes, there is. My website is quite lacking, but the Reshaper software is up to snuff with VW 2009. If you want to try a DEMO, send me the last 6 digits of your VW Serial Number and I'll send you the software and a KEY. It's free for 30 days. It will make positioning of 3D objects quite easy, compared to the confusion you are probably having.

    Raymond

  6. Would it help if the origin was 3D?

    ???I think it would help a lot of people if the User Origin was completely definable as an XYZ offset from the Absolute Origin. But, more than that, if all the readouts (OIP, DataBar, Floating DataBar, Rulers) showed the same coordinates it would make huge difference in how people perceived working in 3D with VW. Being able to select whether the display showed Absolute or User coordinates would be icing on the cake, but this is all just my opinion.

    Raymond

  7. When you move the 2D origin the Rulers move with it. The 3D Origin remains where it was.
    Hi Mike,

    ???I think the second sentence is not entirely true, but depends on what you use as your basis of reference. The problem is that there are too many bases that conflict with each other; Rulers, Data Bar / Floating Data Bar, OIP, Pink Drawing Grid; and no way to force them to be consistent. This is a major shortcoming in the User Interface. An option to align them, to show or hide the shift, would be a huge step forward in the "Ease Of Use" category.

    ???The OIP does show an origin shift in 3D views, but not for every 3D object. Check out 3D Polygons and use the OIP to investigate the coordinates of the vertices; or place a Sphere, or 3D Symbol, in a drawing and the OIP will report its center with the origin shift in all views. The X & Y values show the shift, while the Z value remains fixed.

    ???This is the philosophy I have taken with Reshaper, to show the XY origin shift in all views, as it is what the user is most likely expecting to see. Additionally, Reshaper also reports 2D & 3D positions side by side, allowing the user to work in the reference frame that is most meaningful at the time. Keeping it consistent was one of the hardest things I have ever achieved.

    Raymond

  8. Hi Michael,

    ???I have not seen this. Could you post a file that shows this and outline the steps you used to see the shift in Z?

    ???In developing Reshaper I do extensive testing of 3D objects in 3D space; on Design Layers, in Symbols, in Groups and other container objects, all with and without a shifted origin. In all that time I have not seen the Z value move with respect to an origin shift. If it is happening, I would love to see a file that shows this.

    ???When you say the Z value moves, are you referring to the coordinates reported along the bottom of the drawing window when you hover your 2D or 3D cursor over an object? Or, are you using the OIP to report XYZ values? The data display bar at the bottom of the drawing window and the Floating Data Bar do not show origin shifts in 3D views. It's very confusing, and I consider it a bug, but it's been that way "forever". The OIP, when it does show position, shows the origin shift in a fashion more consistent with the user's expectations. On the other hand, Reshaper shows everything you want to see, the way you want to see it. (Couldn't resist.)

    ???To test coordinates and displayed readouts, I suggest placing 3D Loci at known points and use them to gauge where things are.

    ???As to your wish, it's a popular one.

    Raymond

  9. There is a slight difference in how the two tools work that in my mind would make them a little difficult to merge. The 2D Move tool moves objects in the screen plane, both 2D and 3D objects alike. X offset means move to the right or left, while Y offset means move up or down, all relative to the current view.

    The 3D Move tool moves 3D objects along the absolute X Y & Z axes, regardless of the view. This is where I've stopped thinking how to proceed. Any suggestions how it should work as one tool?

  10. Hi Petri,

    There are two undocumented commands, but they work on individual objects.

    HScale2D(h: HANDLE; centerX, centerY, scaleX, scaleY: REAL; scaleText: BOOLEAN);

    HScale3D(h: HANDLE; centerX, centerY, centerZ, scaleX, scaleY, scaleZ: REAL);

    HScale3D does not work for Groups of 3D objects.

    For 3D Groups I scale from the top with HScale2D using Scale_X and Scale_Y, then from the front using Scale_X=1 and Scale_Z. A Redraw will be needed to see the results.

    HTH,

    Raymond

×
×
  • Create New...