I3erk Posted July 16, 2008 Share Posted July 16, 2008 I am trying to either find or create a script that will allow me to create an object (like a rectangle) and have the long dimension integrated into the object (placed right above it). Also, i need the dimension value to change as the objects length changes too. so if anyone can help me start off with writing this script (never written one before), or if they know if something similar exists already it would be a big help. Quote Link to comment
Pat Stanford Posted July 16, 2008 Share Posted July 16, 2008 Have you considered using associated dimensions for this? With Associated Dimensions turned on (in Document Prefences), you can put dimensions that will change as the object changes. If you draw a rectangle and put an associated dimension on it, it will move with the object and change as the rectangle changes length. If you really want only a single object, you could group the rectangle and dimension together. Is there some special reason you thing you need a script to do this? What is it you are really trying to do. There might be easier ways to do it. If you do decide to script it, it will probably need to be a Plug-In Object so the dimension will update when you change the rectangle. Not hard, but multiple hours of work especially if you put the learning curve into it. Pat Quote Link to comment
I3erk Posted July 16, 2008 Author Share Posted July 16, 2008 Hey Pat, thanks. what i am trying to do in the end is to have like beams, joists and such, with the dimension attached to it and showing without having to draw and attach a dimension line to the object. having a plug-in object like this will make it much easier since the drawings and plans could have tons of wall/floor parts in the same area. It would be a pain in the ass to have to draw all the dimensions lines for each object. so thats pretty much why i would need something like this. Quote Link to comment
I3erk Posted July 16, 2008 Author Share Posted July 16, 2008 oh, and associated dimensions is turned on, and i use that regularly. but for larger drawings, a plug-in object would make life much easier and save alot of time. Quote Link to comment
Pat Stanford Posted July 16, 2008 Share Posted July 16, 2008 OK, try this and see what you think. Go to the Tools menu : Scripts : VectorScript Plug-In Editor Click the New button. Give the plug-in a name. I suggest starting it with an exclaimation point! this will get it to sort to the top of the list. Click the Rectangle Object button and click OK. Click the Script... button and paste the following into the editor window and click OK. {*********** Copy from Here ***********} Procedure DimmedRect; Begin Rect(0,-pBoxWidth/2,pLineLength,pBoxWidth/2); Moveto(0,0); Lineto(pLineLength,0); DimText; End; Run(DimmedRect); {*********** To Here ***********} Click the Done button. Go into the workspace editor and add your new tool to a tool palette. As written, this will let you draw a line down the center of the object and then across half the bottom (while ghosting both sides.) This is just a very basic start, but might give you an idea. Pat Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 Thanks alot. This should get me started pretty well. 1 thing tho, is there a way to show a dimension and not have the dimension ticks showing ? ( like in architecture, they are -/---------DIM---------/- so like, to get rid of those " / " while still having the dimension value show. thanks again Quote Link to comment
Pat Stanford Posted July 17, 2008 Share Posted July 17, 2008 Since it is a true dimension, it is being drawn using the active dimension standard (set in the document preferences). You could create a custom dimension standard and then switch to that standard before you draw the line and then switch back before you leave the script. The trick will be to add the dim standard to your template file and make sure that no one moves it to a different position in the list as it is strictly a numerical position index. You will also need to make a custom marker standard to use either arrows instead of ticks or to have a marker type that is so small that you can't see it. I make a rectangular marker with dimensions of Zero. You can do this either from the Attributes Pallette or from Tools:Options:Edit Marker List. Use this marker in your custom Dim Standard. The following should be close to what you want as long as you only have a single custom dim standard set to zero size markers. Procedure DimmedRect; Var OldStd:Integer; Begin OldStd:=GetPrefInt(71); SetPrefInt(71,0); Rect(0,-pBoxWidth/2,pLineLength,pBoxWidth/2); Moveto(0,0); Lineto(pLineLength,0); DimText; SetPrefInt(71,OldStd); End; Run(DimmedRect); Pat Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 thanks again pat. ill work on making a custom marker and see how that goes. Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 i got everything working now pretty much as i want it for the time being, except that the dim text is in a fixed place. is there any way that i can have it move as the rectangle gets larger in width. Quote Link to comment
Pat Stanford Posted July 17, 2008 Share Posted July 17, 2008 What do you mean? Right now it puts the dim line right down the middle. It is the lines Moveto(0,0); and Lineto(pLineLenght,0); You can move it in the width direction by changing the last zero in both of those two lines. If you want a "vertical" line, then make sure you use the same thing in both. You can do whatever kind of math you want using the pBoxWidth to determine where to set the line. Pat Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 is there a way to place the dim line overlapping the top line of the rectangle instead of right thought the middle. that way the dim line will always move with the object and the dim text will always be in the same relative location above the rectangle. cuz right now the dim line is thought the middle, but the text is set at a certain distance away from the dim line. as the rectangle's width gets larger, the dim line still is thought the middle of the rectangle but the dim text remains at that same distance away from the dim line, so instead of the text being above the rectangle, its ends up inside it. so what i am wondering is if there is a way to make sure the text stays above (and outside) the rectangle, even when the width increases or decreases ? Quote Link to comment
Pat Stanford Posted July 17, 2008 Share Posted July 17, 2008 Put the dim line along the edge of the box and change the dim standard so you have the offset you want. Replace the last two zeros from my last post with pBoxWidth/2 Pat Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 WOW, exactly what i needed. how do you know so much about the script code? and thanks so much. it is greatly appreciated !! :grin: Quote Link to comment
Pat Stanford Posted July 17, 2008 Share Posted July 17, 2008 15 years of MiniPascal and VectorScript playing and about 1 million lines of Pascal prior to that. A good place for you to start is in the VW help. From VW select Help and then VectorScript Guide and the VectorScript Reference. Also from the VectorScript Reference go to Additional Resources and select the VectorScript Appendix. If I where you, I would bookmark all three of the above places in my browser if you are going to do much scripting. I actually have the VectorScript Reference open in three tabs in by browser so I can look up multiple functions/procedures at the same time. I recommend that you read the VS Guide, and then go through the script and look up all of the commands in the VectorScript Reference. That will give you a starting point for doing more. You are welcome. Pat Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 hey pat, one other question, how would i add a check box to turn the dim text on or off? kind of like a boolean command Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 Thanks a lot for the info, and your time too. i greatly appreciate it Quote Link to comment
Pat Stanford Posted July 17, 2008 Share Posted July 17, 2008 In the PIO Editor you will click the Parameters button and add a new parameter and set it to be a type of Boolean. In the script put an IF statement around the two lines that draw the dimension. Use a p before the name of the new parameter as part of the if statement. If pNewParameter then Begin Draw Dim Here; End; Pat Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 so it would be Procedure DimmedRect; Var OldStd:Integer; Begin OldStd:=GetPrefInt(71); SetPrefInt(71,0); Rect(0,-pBoxWidth/2,pLineLength,pBoxWidth/2); Moveto(0,pBoxWidth/2); Lineto(pLineLength,pBoxWidth/2); If pTEXT then DimText; SetPrefInt(71,OldStd); End; Run(DimmedRect); Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 what i want to have is a tick box that will either make the dim text show or not show. Quote Link to comment
I3erk Posted July 17, 2008 Author Share Posted July 17, 2008 How would i make an IF THEN ELSE command? like for example... If boolean box is checked then display dim text. If boolean box is not checked then display the text written in the following overide field ( overide value: xxxx ). Quote Link to comment
Pat Stanford Posted July 17, 2008 Share Posted July 17, 2008 I would move the If to above the Moveto If pTEXT then Begin moveto etc. DimText; end; SetPrefInt( For else then some thing like If pText then Begin end else Begin end; Note that there is not semicolon after the end before the else. If you add a parameter it will show in the OIP however you have it defined. Since the dim line is along the side of the box and you don't want markers, why draw it at all if you don't want the text? If you don't draw it then you don't need the else. If checked then dim else do nothing. If you want to take this any further, you really need to read the VSGuide and start digging into the Function Reference. Pat Quote Link to comment
I3erk Posted July 18, 2008 Author Share Posted July 18, 2008 alright. thanks alot. ive started reading the resource guide and everything tongiht. and its going pretty well too. thanks again for evrything 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.