Jump to content

WhoCanDo

Member
  • Posts

    402
  • Joined

  • Last visited

Everything posted by WhoCanDo

  1. With much hope I tried the idea twk but alas to no avail. GetWSPlacement is another non-operational function. procedure test; var hW1 : handle; t1, l1, b1, r1 : real; begin hW1 := CreateWS ('testWS', 5, 5); hW1 := CreateWSImage (GetObject ('testWS'), 0, 0); GetWSPlacement (hW1, t1, l1, b1, r1); Message (t1, ' ', l1, ' ', b1, ' ', r1); SelectObj ((T = 56)); Relative; MoveObjs (l1 - r1, 100, false, false); Absolute; end; run (test);
  2. I placed a worksheet on my drawing using .. hW := CreateWSImage (GetObject ('Schedule'), 0, 0); I would like to place it as follows .. hW := CreateWSImage (GetObject ('Schedule'), 200 - (Width of WS), 200); which will be inside the drawing border at the top right. Since the WS reference point is top left then I need to move it Width(WS) to the left of the border. How do I work out the width of the WS??
  3. Thanks Kevin, That worked. However, the only reason why I used Chr instead of '°' in 2016 is that '°' stoppe working in 2016. Worked fine in previous versions. So, no Alt0176 in macros, no Chr(176) {replaced by 161} in macros, but Alt0176 is still working when typing text within the drawing. A bit of a mishmash hey. I thought VW used the ASCII western character set.
  4. Hi, Can anyone tell me how to get ° into my code/text please? It seems to have been overlooked in VW2016 procedure AngleText; var pt1, pt2, pt3, pt4 : vector; begin GetPt (pt1.x, pt1.y); GetPtL (pt1.x, pt1.y, pt2.x, pt2.y); GetPtL (pt2.x, pt2.y, pt3.x, pt3.y); pt4 := (pt1 + pt3) / 2; TextOrigin (pt4.x, pt4.y); CreateText (Concat (Num2Str (2, AngBVec (pt1 - pt2, pt3 - pt2)), Chr (176))); end; run (AngleText);
  5. Thanks Dieter, you've been a great help. With the code above I suddenly realised that Case Item of SetupDialogC: GetTBdialog1Events; should really be Case Item of SetupDialogC: SetupEvent; which stops all the loops I was originally perplexed about. Thanks again and have a great holiday period.
  6. Thanks Dieter, you are correct. I shall use code tags next time. So how do I stop this repetition? Can you re-sequence my code as you would suggest is the best format so I don't make the mistake again please. What information are you privileged too :-) that allows you to know that 12255 is an init/setup? Where does the average person find this help?
  7. Not clear on what you meant but case 01 obviously runs at startup. So what if I want to add OldTyp := Concat (OldTyp, '1'); into the procedure GetTBdialog1Events; The end result would be 'AA11' because it loops through the case 01 twice. How is that useful?
  8. I still don't understand why, if item = 12255 then case 01 is run.
  9. Additionally I can't add 12255 to the case list to force it not to pick 01 but 12255 seems to be a duplicate case value. Why?
  10. Why does the following loop through No.4 (case 01) before OK is selected? After No.1 I would have expected No.2 to be 0, not 12255. However, even though No.2 is 12255 (which is not a case item) it still runs case 01 (No.4) and then No.3 (still 12255) before the dialog appears in the top left of my screen (why there??). If I choose OK then No.2, No.4, No.3 is correct as I would expect but why does it then go No.2 12256, No.3 12256. Where am I going wrong? procedure Main; var TBdialog1 : longint; OK : boolean; GridTyp, OldTyp : string; procedure CreateTBdialog1; begin AlrtDialog ('1. '); TBdialog1 := CreateLayout ('Data', False, 'OK', 'Cancel'); CreateStaticText (TBdialog1, 4, 'Data Type:', 20); CreateCheckBox (TBdialog1, 5, ' A'); CreateStaticText (TBdialog1, 7, 'Reference:', 20); CreateEditText (TBdialog1, 8, OldTyp, 20); SetFirstLayoutItem (TBdialog1, 4); SetRightItem (TBdialog1, 4, 5, 0, 0); SetBelowItem (TBdialog1, 4, 7, 0, 1); SetRightItem (TBdialog1, 7, 8, 0, 0); end; procedure GetTBdialog1Results (var Item : longint; Data : longint); procedure GetTBdialog1Events; begin GetBooleanItem (TBdialog1, 5, OK); GetItemText (TBdialog1, 8, GridTyp); UprString (GridTyp); AlrtDialog (Concat ('4. ', GridTyp)); end; begin AlrtDialog (Concat ('2. ', Num2StrF(Item))); Case Item of SetupDialogC: GetTBdialog1Events; 01 : GetTBdialog1Events; 02 : ; { Cancel } end; { case } AlrtDialog (Concat ('3. ', Num2StrF(Item))); end; begin OldTyp := 'AA'; CreateTBdialog1; If (RunLayoutDialog (TBdialog1, GetTBdialog1Results) = 1 { OK }) then begin end; end; run (Main);
  11. Here's what I am trying to do (attached). If I draw "1" then I want the macro to fillet the corners, create a profile and extrude along path. As you can see, if I fillet the corners with the fillet tool and I use a macro that I have already written then I get what I want. But why should I fillet the corners when VW can do it. If I change this 3D Polygon to a ConvertToPolyline then I can SetPolylineVertex but when VW ConvertToPolyline it flattens the polygon to 2D. The only solution is to CreateNurbsCurve to which I have to AddVertex3D and that's why I wanted to understand the fillet mathmatics. The only other option I have is to call the fillet tool during the macro so the operator can fillet the corners and then the macro will continue to extrude a pipe. Can you suggest any alternatives? :-)
  12. After seeing this - https://en.wikipedia.org/wiki/Non-uniform_rational_B-spline I think it's all too hard for me. I think this should be on the wish list since VW has already created the Fillet Tool which works on nurbs curves, all we need them to do is create a procedure or function we can use. Something like h1 := FilletPath (h, 140, var error); which fillets any type of line in 2D or 3D and returns an error code if it can't do it or one of the fillets is less than the required radius. Anyone else want to comment before I wish it?
  13. Thanks Josh, I've tried that but even though my example is top view, it could just as easily have a twist (z) factor. If it has a z value then ConvertToPolyline vertically flattens the shape which changes the angle between the lines. I have nearly finished this macro but I just need to add the vertices to make a proper radius fillet. Someone wrote the fillet tool in the first place so someone should know the answer to this question.
  14. How do you calculate the Vertex points for a fillet in a Nurbs Curve? On the attached I have drawn a 1000 x 1000 @ 20° angle using the 3D Polygon Tool. I then filleted the angle @ R140 using VW Fillet Tool. When you double click the result you see 6 vertex points. The tangent (Adj = 794) is easy to find but how does VW locate the two vertices at 589 ? I am planing to calculate and AddVertex3D but unless someone can come up with a better idea then I need to find these other two points to finish the fillet.
  15. Excellent Raymond, Yes I can understand the problem of finding that Insert point when the angle changes so I'll work on that next. I did try changing the last vertex but I didn't think of the relationship between them which would be broken by adding the vertex. Regards
  16. Thanks Hip, but I can't get a grasp on the extrude process. If you use the following to create an extrude-along-path + the new profile, how do I replace the 20mm profile with the new 50mm profile? procedure test; var BTmp : boolean; h1, h2, h3, h4, h5 : handle; PipeOD, WallWdth : real; begin h1 := FSObject (ActLayer); if (GetType (h1) <> 86) then begin Poly3D (5, -5, 0, 300, -300, 0, 300, -757, 0, 5, -462, 0); h1 := ConvertToPolyline (LNewObj); SetPolylineVertex (h1, 2, 300, -300, 3, 140, true); SetPolylineVertex (h1, 3, 300, -757, 3, 140, true); end; if (GetType (h1) = 21) then begin PipeOD := 20; WallWdth := 4; Oval (-PipeOD/2, PipeOD/2, PipeOD/2, -PipeOD/2); h2 := LNewObj; Oval (-PipeOD/2 + WallWdth, PipeOD/2 - WallWdth, PipeOD/2 - WallWdth, -PipeOD/2 + WallWdth); h3 := LNewObj; ClipSurface (h2, h3); h4 := PrevObj (h3); h5 := CreateCustomObject ('Extrude Along Path', 0, 0, 0); if (SetCustomObjectProfileGroup (h5, h4)) then begin end; if (SetCustomObjectPath (h5, h1)) then begin end; DelObject (h2); DelObject (h3); h1 := LNewObj; end; if (GetType (h1) = 86) then begin PipeOD := 50; WallWdth := 4; { Create New Profile } Oval (-PipeOD/2, PipeOD/2, PipeOD/2, -PipeOD/2); h2 := LNewObj; Oval (-PipeOD/2 + WallWdth, PipeOD/2 - WallWdth, PipeOD/2 - WallWdth, -PipeOD/2 + WallWdth); h3 := LNewObj; ClipSurface (h2, h3); DelObject (h2); DelObject (h3); h2 := LNewObj; { Replace Old Profile } { h3 := GetCustomObjectProfileGroup (h1); if (SetCustomObjectProfileGroup (h3, h2)) then begin end; if (SetCustomObjectPath (h3, h2)) then begin end; } end; end; run (test);
  17. Since no-one has responded I have submitted this as a bug.
  18. Try either of the SetPolylineVertex lines below independently and they work but allowing both to run produces an object with the bottom right curve at 94.65° but not the 140° as required. Any ideas as to how I can get this working? procedure test; var h1 : handle; x, y, vertexType, vertexRadius : real; begin Poly3D (5, -5, 0, 300, -300, 0, 300, -757, 0, 5, -462, 0); h1 := ConvertToPolyline (LNewObj); GetPolylineVertex (h1, 2, x, y, vertexType, vertexRadius); SetPolylineVertex (h1, 2, 300, -300, 3, 140, true); { SetPolylineVertex (h1, 3, 300, -757, 3, 140, true); } end; run (test);
  19. I've battling the for a couple of days now and can't get my head around Poly3D and then I discovered that it's GetPt3D that's throwing me off. procedure test; var vec1 : vector; h1 : handle; begin DSelectAll; GetPt3D (vec1.x, vec1.y, vec1.z, false); Poly3D (5, 0, 0, 300, 0, 0, 300, -457, 0, 33, -457, 0); h1 := ConvertToPolyline (LNewObj); SetPolylineVertex (h1, 2, 300, 0, 3, 90, true); SetPolylineVertex (h1, 3, 300, -457, 3, 90, true); end; run (test); In front view I get a different result with and without GetPt3D. I want the Poly3D to be on the top view no matter what view I am in so what's going wrong? If you test the above without GetPt3D and in any view then you get the result I want but I want to ask the user where they want the result to be after creating it.
  20. I can get my macro to edit the profile if the user chooses "Path" when EditObjectSpecial (h, 4); is used, but I don't want user input. How do I edit or delete and replace the profile in Extrude Along Path?
  21. GetPt3D will select a 3D point but how do you pick the object at that point? If I run a macro that wants a 3D object to be selected but I have forgotten to pick the object before the VS runs then how do I allow the operator to select and object while in 3D view?
  22. Isn't GetLine3D suppose to pick points from different Z planes? I have a Locus on Z+200, Z0, Z-200 & X100,Z0 If I run the following macro then I can pick any locus first but no other if I am in any view other than iso and then only the one on the Z0 plane. Surely I should be able to pick any loci being this is a 3D tool and set to False. Can anyone suggest a reason for this or a way around this? procedure test_this; var p1X, p1Y, p1Z, p2X, p2Y, p2Z : real; begin GetLine3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z, false); Poly3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z); end; run (test_this);
  23. Thanks Guys, Yes Miguel, the technical explanation was exactly what I needed. Regards
  24. With GetLine3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z, false); I can get the beginning and end point of a 3D line but if I want to calculate the points 5mm shorter at one end or 5mm shorter at the other end then how can I calculate this? procedure test; var h : handle; p1X, p1Y, p1Z, p2X, p2Y, p2Z : real; begin GetLine3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z, false); Poly3D (p1X, p1Y, p1Z, p2X, p2Y, p2Z); h := ConvertToNurbs (LNewObj, false); Message (LengthN (Sel=True)); end; run (test);
  25. At the moment (VW2014) the script editor for macros contained within each sheet is restricted to 32000 characters which seems to relate to the 32 bit environment. I can cut and paste or write more characters but only when saving the script is the problem is highlighted. $Includes and plugins are not an option for portability or security of code so please fix this asap. Regards
×
×
  • Create New...