Jump to content

MullinRJ

Member
  • Posts

    2,017
  • Joined

  • Last visited

Posts posted by MullinRJ

  1. Nearly 2 years ago I posted a PDF of an annotated VW Pref Constants to the Techboard. It's not a complete listing of all preferences, but it has all of the VW prefs that you can set from the VW Preferences Dialog. Document Prefs and Unified View Prefs windows can be found in the second posting in the following thread. Of course, some new settings may have been added since then, but not too many have been.

    You can find the PDF files here: VW Preference Constants

    HTH,

    Raymond

  2. The Use Layer Color pref constant is 11. A list of constants can be found in the VectorScript Function Reference Appendix.

    The following one line script can be used to toggle the Use Layer Color preference:

    SetPref(11, not GetPref(11));

    Raymond

  3. I was surprised last week when I opened an old file for someone and found that VW 2012 opens files all the way back to MC 7 format. I'm sure NV has mentioned this at some point, but I think they should mention it again and say it a little louder and more often. This gives the software quite a bit of flexibility that it did not have before.

    As for saving VW files, VW 2012 will save back to VW 12 format.

    Raymond

  4. You can also save a file as a template using the menu File>Save As Template... It will be saved in your User folder.

    I have created several templates for starting new documents where I set the Font, Units, Page Scale, Dimensions, and Script Palette. The big distinction for me is the Units (mm, microns or inches). Obviously, your needs will differ from mine, but the concept is the same. You can also add record formats, spreadsheets, layers, viewports, symbols and other resources you use all the time. For resources you use sometimes, save them in a library file.

    HTH,

    Raymond

  5. I tried the script on a small file and it did not crash. Perhaps it has to do with a specific object in your file. In a copy of your file, you might try removing symbols to try and locate the offending object. If it still crashes with an empty symbol folder then it is something else. Write back with more info and hopefully someone will be able to help further.

    Please, work in a COPY of your file.

    Raymond

  6. Hi Pat,

    ???Your script will only work on the first layer. NextObj() will return NIL at the end of the first layer and will not return a handle to the first object on the second layer. Of course, if your file only HAS one layer, it works perfectly.

    ???You could encase your loop inside a loop that steps through the layers and use FActLayer instead of FObject (been there, done that), but I'd suggest using ForEachObject() or ForEachObjectInLayer() which will step through every object in the drawing. Using the GROUP or DEEP options in the latter call will remove the need for recursion.

    ???This example is definitely not as sexy as your example, but it's fast and thorough; and like your example, it's untested, so caveat emptor and always wear your galoshes when it's raining.

    Procedure UnlockAll;
    
    function Unlock(ObjHandle: Handle) :Boolean;
    Begin
    	SetObjectVariableBoolean(ObjHandle, 700, False);
    End;		{ Unlock }
    
    BEGIN
    ForEachObjectInLayer(Unlock, 0, 1, 1);	{ All Objects, All Layers, Enter Groups }
    END;
    Run(UnlockAll);
    

    Raymond

  7. I don't think that is a feature that has an On/Off preference. If you are in the act of selecting objects, the screen will scroll when you get close to the edge. If your mouse button is not down, or you haven't clicked to start selecting, the screen shouldn't scroll when you get close to the edge with the pointer. Are you seeing differently?

    Raymond

  8. James,

    Change:

    ???Procedure RotTest(h : HANDLE);

    To:

    ???Function RotTest(h : HANDLE) :Boolean;

    All of the ForEachObj... VS calls take a FUNCTION as the callback "procedure" except ForEachObject(), which takes a PROCEDURE as the callback "procedure".

    If you want to terminate the loop early, then the callback "function" needs to return a TRUE value. By default, it will return a value of FALSE, even if it's not explicitly stated, and continue to the end.

    As to whether your callback will do what you want, I don't know.

    Raymond

  9. Can you set your screen resolution to a larger value? If the palettes are off screen, this is one way to get access to them. Or, try hooking up to a larger monitor (variation of same trick). Move them back to where you can find them and quit VW. Their positions will be saved in your current workspace and used the next time you run.

    If you use a laptop and large screen alternately, you should duplicate your current Workspace and set the palette positions for each environment accordingly - Laptop WS and Desktop WS. Use your Laptop Workspace for small screen work and your Desktop Workspace for large screen work. Keep everything else the same.

    Good luck on your exam. After your exam, please create a signature so our answers can be better directed to your specific needs.

    HTH,

    Raymond

  10. hermann,

    Yes, 2D objects will show in 3D views. You have 2 options, use a Hybrid Symbol or a Plug-In Object (PIO). A symbol is the easier way. A PIO is more flexible, but requires a bit more programming.

    As you have found, 2D only symbols will show in both 2D and 3D. Only when a symbol has both 2D & 3D parts (Hybrid Symbol) will it show one or the other as the view changes. You shouldn't have to place this symbol inside a PIO to get the behavior you described. It should work just by placing it in the drawing.

    Remember though, 2D objects that are created on the Layer Plane are really 3D objects and will show in 2D and 3D views. You will need to make sure your 2D objects are Screen Plane objects if you wish them to vanish in 3D views.

    If you want to show a 2D part without a 3D part, you can put a 3D Locus in your Symbol, place it in a "HideMe" class and hide that class. This will create the 3D side of your hybrid symbol and keep it invisible.

    ???Locus3D(x, y, 0);

    ???SetClass(LNewObject, 'HideMe');

    ???HideClass('HideMe');

    To keep the selection handles consistent in 2D & 3D views, place the Locus inside the Symbol's 2D boundary. Even when the 3D part is hidden, it will still show a selection handle when it is selected.

    Raymond

  11. This appears to be a bug. I tried preallocating the Dynarray to a value larger than one you needed, but your assignment still brings the allocation back to 13. Not good.

    PROCEDURE TestString;
    CONST
    LargeNumber = 32767;	{ max 32767 }
    VAR
    shortstring		: STRING;
    aString		: DYNARRAY OF CHAR;
    
    
    PROCEDURE ChgText(VAR varString: DYNARRAY OF CHAR);
    BEGIN
    	varString := 'The string has been modified';
    END; 
    
    BEGIN
    Allocate aString [1 .. LargeNumber];
    
    aString := 'Only 13 chars';
    
    ChgText(aString);
    shortstring := aString;
    Message(shortstring );
    END;
    run(TestString);

    Raymond

  12. In the end, for the special case of only 2 vertices, I simply drew a line between start and end then converted to polyline with the aid of the very useful LNewObj function making it a cinch. Oddly enough, it created a 2 vertex polygon!

    Actually, it's not that odd. Polygons are really a degenerate case of Polylines. Remove all the curvy parts, show all the sides, and you've got a Polygon. Since a Line has no curvy parts, it defaults to becoming a Polygon when converted. You can create a Polyline with only Corner Points, but you have to be careful you don't cajole VW into "downgrading" it for you. The method I outlined above is the only way I know of to create a 2-vertex Polyline via VS. There may be others, but I usually stop looking after I find the first way that works.

    I agree with you that VS is a function-rich language, but I don't think of the language as feature poor, but rather the compiler. VS is not a fully implemented version of Pascal, allocating memory for structures like Linked Lists is missing, and a few other features, but as a whole, it is still very powerful. Of course, there's always the SDK, but you have to get really dirty to develop there. For "quick and easy", it's VS. OK, that last line can be taken with a grain of salt, but there really are a lot of quick and easy uses for VS.

    Reusable code is not that hard to generate, but it all hinges on the discipline and experience of the programmer. VW does not really facilitate the programming side of things and it is up to the individual to ferret out the details. That said, I have gotten excellent support when needed from the people at NV. Vlado, for one, has been invaluable and enlightening in really tough situations.

    If you want to get more out of VW through "scripting", stay connected to like minded people.

    Welcome to the mix,

    Raymond

  13. The VectorScript Message window is just a place that scripts can write messages for you to read. Sometimes, the script will close the Message window, sometimes not. You may close it at any time.

    As to the contents of that particular message, it is only relative to the task you were doing at the time it appeared. If it were a more serious message / warning / error, it probably would have appeared in an Alert Dialogue.

    Someone else will have to help you with your title block problem.

    Raymond

  14. I've noticed if you are in the Screen Plane drawing mode and you set the Working Plane with the WP Tool then select a 2D tool, the active plane jumps back to Screen Plane.

    If you were in Layer Plane mode before using the WP Tool, you'll stay in Working Plane mode when you select a 2D tool.

    To get things right, check the Active Plane menu at the top of the screen after you select your first 2D tool and make sure you are in Working Plane mode. The next time you switch tools you should stay in the WP mode.

    If you set the drawing plane back to Screen Plane, even if you have a Working Plane set, you'll have to manually set the menu back to WP again to continue drawing on the WP. OR, if you already have a planar 2D object drawn on a WP, then double click on it to activate that WP.

    Raymond

  15. You're welcome, Ian. If you don't mind adding functions to your code, as in breaking from inline coding, try this one. Calling it will simplify the main loop keeping the hard part of your code more readable and concise. If you don't want or need the handle to the Poly, then you can redefine the function as a procedure.

    Raymond

    	function TwoPtPoly(P1, P2 :Point; Polygon :Boolean) :Handle;
    { Create a 2-vertex polygon if Polygon is TRUE, or a 2-vertex polyline if Polygon is FALSE. }
    { Return a handle to the new object. }
    Begin
    	BeginPoly;
    	    MoveTo(P1.x, P1.y);
    	    LineTo(P2.x, P2.y);
    	    LineTo(P2.x, P2.y);  			{ Dummy vertex }
    	EndPoly;
    	if Polygon then DelVertex(LNewObj, 3)  		{ Makes it a Polygon }
    	else SetVertexVisibility(LNewObj, 1, FALSE);	{ Makes it a Polyline }
    	TwoPtPoly := LNewObj;
    End;		{ TwoPtPoly }
    
    BEGIN
    OpenPoly;
    Smooth( 0 );
    IF ( objCount < 2 ) THEN
    	AlrtDialog( 'Two or more objects need to be selected' )
    ELSE IF ( objCount = 2 ) THEN
    	H1 := TwoPtPoly(P1, P2, True)	{ TRUE = polygon, FALSE = Polyline }
    ELSE BEGIN	{ 3+ objects }
    	BeginPoly;
    		FOR obj := 1 TO objCount DO
    			...
    	EndPoly;
    END
    
    END;

  16. That's interesting, because I can manually create a polyline with 2 vertices and it remains a polyline.
    I guess if I used the right tool it would have been easy. As you say, it's Friday and not all brain cells are on task.

    VS, to the best of my knowledge (which is obviously limited), does not have a straightforward way to generate 2-vertex Polylines. Even the 2-vertex Polyline that you can draw manually does not export as VS such that you can re-import it and get back to where you started.

    However, there are usually circuitous paths around most obstacles. I stumbled on this one only moments ago.

    BeginPoly;

    ????MoveTo(1, 2);

    ????Lineto(3, 4);

    ????Lineto(3, 4);???{ Dummy vertex }

    EndPoly;

    SetVertexVisibility(LNewObj, 1, FALSE);???{ Makes it a Polyline }

    Just duplicate the last vertex and hide a side. You'll end up with one less vertex and no hidden sides ( just as you'd surmise :-p ). If it weren't for guessing, programming VS wouldn't be any fun.

    If you want a Polygon instead, then delete the third vertex as shown in my previous post instead of using SetVertexVisibility().

    HTH,

    Raymond

  17. The script is simple and should not crash VW. I tried it from a Script palette and it worked as expected. I also tried it as a Menu command and it worked there, too. Even as a tool, it worked, but it should be noted that tools wait for an initial click in the drawing to begin execution, so there will be an extra click in your script, the first activates the tool, the second gets the point for GetPtL(), and then the tool goes back into waiting mode so the tool icon will remain dark (depressed) until it is deselected.

    You say you have this in a PIO. could you elaborate more? Point, Path(2D/3D), Linear, Rectangular? I suspect there is another cause beyond this call causing the crashes.

    Raymond

  18. Ian,

    ???I don't know of a direct way to create a Polygon or a Polyline with 2 vertices. Manually, you cannot draw only 2 vertices, as it will become a Line. If you draw 3, you cannot delete one vertex if it is a Polygon. However, you can delete one vertex if it is a Polyline (go figure).

    ???The backdoor approach (via VS) is to create a 3 point Poly (-gon or -line) and then delete a vertex.

    This works to produce a 2 vertex Polygon:

    BeginPoly;

    ??Addpoint( 1, 2 );

    ??Addpoint( 3, 4 );

    ??Addpoint( 3, 4 ); { Dummy point }

    EndPoly;

    DelVertex(LNewObj, 3);

    ???Your best option (meaning one that will be supported in all future versions of VW) is to create a Line when you have 2 vertices and a Poly when you have 3 or more. If you absolutely need it to be a Poly, then try the above method.

    Good luck,

    Raymond

    PS - Please avoid One-Point-Polys. They will confuse everybody. ;-)

  19. Dave, You are very welcome. I filed a bug report referencing this thread, so maybe it won't be a bug for long.

    The Rectangle and Rounded Rectangle seem to be the only shapes that receive the gradient fill from the FillPat() command. Arcs/Circles, Polys, Polylines and Ovals do not. For these shapes, use the manual method from above.

    Raymond

  20. Dave,

    ???I think you've found a bug. The gradient fill should display inside the Poly with the FillPat() setting. The OIP shows there is a gradient, but does not show it. It also fails for Ovals and Arcs. Only Rects seem to be showing the fill correctly. I'm going to submit a bug and reference this thread.

    ???I am not familiar with the commands SetFillOriginPoint() and SetFillIAxisEndPoint(). It seems like they should work for what you want, but don't, so I tried commands that I know will work. I've modified your code below.

    ???The offsets for the Gradient Origin are set with the FIll X and Fill Y Offsets and are relative to the object's center (which I originally found by trial and error). The Fill I-Axis Length is the width of the object in your case, since your fill is horizontal. If you set your fill at an angle, then you will need to specify Fill Y Offset (objVar 111) and Fill J-Axis Length (objVar 113) which in this case are both 0 by default. And note, the rotation angle of the Gradient (objVar 74) is specified in Radians, not Degrees.

    PROCEDURE Gradient2;
    CONST
    GradName = 'Black-White';
    VAR
    SegmentIndex : INTEGER;
    hGrad : HANDLE;
    
    BEGIN
    {---------------------------------------------Create gradient}
    hGrad := GetObject(GradName);
    if (hGrad = nil) then hGrad := CreateGradient(GradName);
    SegmentIndex := 1;
    SetGradientData(hGrad, SegmentIndex, 0, 0.5, 0, 0, 0);
    SegmentIndex := 2;
    SetGradientData (hGrad, SegmentIndex, 0.75, 1, 255, 255, 255);
    
    {-------------------------------Sets fill pattern to gradient}
    FillPat(-Name2Index(GradName));
    
    {--------------------------------------------Create rectangle}
    Rect(0, 0, 100, 100);	{ receives fill from FillPat() }
    
    {------------------------------------------------Create poly}
    ClosePoly;
    Poly(-100, 100,  -100, 0,  0, 0,  0, 100);
    
    {-------These shouldn't be necessary, but they make the Poly fill show}
    SetObjectVariableReal (LNewObj, 110, -50);		{ Fill X Offset - relative to object center }
    SetObjectVariableReal (LNewObj, 112, 100);		{ Fill I-Axis Length }
    SetObjectVariableReal (LNewObj, 74, 0);			{ Fill Angle (radians) }
    SetObjectVariableLongInt (LNewObj, 78, 1);		{ Gradient Geometry Type - 1 = Linear }
    
    END;
    RUN (Gradient2);
    

    Raymond

  21. You can assign a record to them and add "Database Records" to your selection criteria. If you do it to the first one, then each time you duplicate it it will have that record format attached. You don't need any data in the attached record, just have it attached. For different size rectangles, assign a different record format. Use this like sub-classing.

    Raymond

  22. SetObjectVariableReal(FSActLayer, 74, Deg2Rad(10));

    will set the Gradient angle to 10 degrees in the first selected object on the active layer, assuming it has a gradient fill.

    I played with Gradients extensively 5 years ago and it was not easy. Luckily, I've forgotten most of the headaches. Your best bet to see how they work is to create an object with a gradient fill, duplicate it and distort the copies, then export the file to a VectorScript file and try to see what changes among your objects.

    The good news is Image Fills are worse.

    As Dave Carpenter pointed out, the angle must be expressed in Radians.

    HTH,

    Raymond

×
×
  • Create New...