Jim Clayton Posted December 4, 2019 Posted December 4, 2019 I have the attached AutoDimension Lisp that I picked up somewhere a while back. It seems to work well except that it currently is set for "Dim-Aligned". I need it to be set to "Dim-Linear". I wasn't able to find any clear point in the Lisp where I could make that adjustment so I was hoping for a fresh set of eyes on it. Thanks for the help. AD-Automatic Dimension Autocad.LSP Quote
ronjonp Posted December 5, 2019 Posted December 5, 2019 22 hours ago, Jim Clayton said: that it currently is set for "Dim-Aligned". I need it to be set to "Dim-Linear". @BIGAL Quote
Jim Clayton Posted December 5, 2019 Author Posted December 5, 2019 I found that line before posting to the forum. I tried changing it to vla-adddimlinear, but all it did was make the Lisp stop working. Quote
ronjonp Posted December 5, 2019 Posted December 5, 2019 All I see available are these: Quote vla-AddDim3PointAngular vla-AddDimAligned vla-AddDimAngular vla-AddDimArc vla-AddDimDiametric vla-AddDimOrdinate vla-AddDimRadial vla-AddDimRadialLarge vla-AddDimRotated Quote
Jim Clayton Posted December 5, 2019 Author Posted December 5, 2019 well hell...that's not any good. Let me keep messing with it. Maybe I'll stumble across it. I appreciate the help. Quote
Lee Mac Posted December 5, 2019 Posted December 5, 2019 FYI vla-adddimrotated will create a 'linear' dimension. Quote
Jim Clayton Posted December 5, 2019 Author Posted December 5, 2019 Would I be overriding "vla-adddimaligned" or does this need to be placed elsewhere. Please and thank you. Quote
pkenewell Posted December 5, 2019 Posted December 5, 2019 (edited) You would replace: (vla-adddimaligned space (vlax-3d-point p1) (vlax-3d-point p2) (vlax-3d-point p3)) with: (vla-adddimrotated space (vlax-3d-point p1) (vlax-3d-point p2) (vlax-3d-point p3) 0.0); You will need to determine the angle of the dims you want. However: additional code will be needed to determine the rotation angle you want (i.e. Vertical - 0.0 1/2 pi or Horizontal - 1/2 pi 0.0). What is the criteria? if the angle of p1, p2 is closer to vertical than horizontal? Also you will have to use the same criteria to determine the dimline location (p3) Edited December 9, 2019 by pkenewell Quote
Jim Clayton Posted December 6, 2019 Author Posted December 6, 2019 Well I'm gonna be honest with you...I'm not sure I have the abilities to decipher that last bit of information. I'm still very green to all of this. So this may have to take a back burner till I get a bit more knowledge under my belt. Regardless, I appreciate the help. Quote
Jonathan Handojo Posted December 7, 2019 Posted December 7, 2019 In simple terms, the value 0.0 in the last post denotes the angle of your dimension, measured in radians. At 0 degrees, you're creating a vertical linear dimension, and at 90 degrees (or 0.5pi), you're creating a horizontal dimension. At any other value, the dimension will be rotated differently again. Quote
pkenewell Posted December 9, 2019 Posted December 9, 2019 (edited) Actually - correction in my last post: Vertical would be 90 degrees or 0.5 x pi in Radians, and Horizontal would be 0 degrees or 0.0 Radians. Rotation angle is the angle of the Dimension line. Edited December 9, 2019 by pkenewell Quote
Jim Clayton Posted December 10, 2019 Author Posted December 10, 2019 I think i'm slightly smarter today because when I read through those again it wasn't as confusing. That's good to know. Okay so, most everything is should be horizontal if i'm understanding that correctly. It's always going to be either vertical or horizontal. Now i'm wondering if there's a way to add a prompt to switch betwixt the two. I'm going to try messing with this to see what sort of damage I can do. Thanks all for your help. Quote
Jonathan Handojo Posted December 10, 2019 Posted December 10, 2019 4 hours ago, Jim Clayton said: I think i'm slightly smarter today because when I read through those again it wasn't as confusing. That's good to know. Okay so, most everything is should be horizontal if i'm understanding that correctly. It's always going to be either vertical or horizontal. Now i'm wondering if there's a way to add a prompt to switch betwixt the two. I'm going to try messing with this to see what sort of damage I can do. Thanks all for your help. Not always. If you set your rotation angle to, say, (/ pi 3) radians, then your dimension will be rotated 60 degrees from horizontal. That angle can be set to any value you want, but when you use the DIMLINEAR command, the result is normally at 0 radians or 0.5pi radians. Quote
pkenewell Posted December 10, 2019 Posted December 10, 2019 (edited) 1 hour ago, Jonathan Handojo said: Not always. If you set your rotation angle to, say, (/ pi 3) radians, then your dimension will be rotated 60 degrees from horizontal. That angle can be set to any value you want, but when you use the DIMLINEAR command, the result is normally at 0 radians or 0.5pi radians. @Jonathan Handojo As Jim stated originally, he wants linear dimensions (like those created with the DIMLINEAR command), so the rotation would always be 0.0 or 1/2pi in the current UCS. Otherwise (any other angle) it would be like the DIMROTATED command instead. @Jim Clayton Note that you will have to translate the points (p1 p2 and p3) from the current UCS to the WCS coordinates if you are working in any other UCS but World. It usually always makes sense to do a (trans pt 1 0) to the points before plugging them into the (vla-adddimrotated) function. EDIT: In terms of the original Lisp, the (vlax-curve...) functions already return the points in WCS, so ignore my statement above if you are still using that method. I think you will have to rewrite part of that code for the p3 point, but you could still use the same method to get the p1 and p2 points and the mid point (pm). You will however have to change the polar coordinate for p3 to offset inward or outward the difference in X (for vert) or Y (for Horiz) of p1 and p2, plus the ht variable. You could still even use the second derivative (sd variable) that determines the normal to get the "inside" or "outside" (d variable as + or -), but determine p3 based on 0 or pi instead of the normal angle [ expressed in original as "(+ (atan (/ (sin u) (cos u))) (/ pi 2.0))"]. I would leave the arc dimension code alone. Edited December 10, 2019 by pkenewell Quote
pkenewell Posted December 10, 2019 Posted December 10, 2019 (edited) Ok - you got me inspired to give this a try. See the attached LISP file. Still working on it, but it will do what you want for the most part. NOTE: This works - kind of. I have to do a better determination of the direction of the polyline to get CW or CCW I think in order to get all the dims "inside" or "outside". UPDATED: Got everything working, with the help of Gile's (gc:clockwise-p) function and some other edits! try this! AD-Automatic Dimension Autocad (3).LSP Edited December 10, 2019 by pkenewell New file version 1 Quote
Jim Clayton Posted December 11, 2019 Author Posted December 11, 2019 That's perfect! @pkenewell you're a genius...this is going to save loads of time. I greatly appreciate all the help. Thanks again! Quote
pkenewell Posted December 11, 2019 Posted December 11, 2019 (edited) @Jim Clayton Thanks! Much appreciated. I found the challenge irresistible in this case. FYI - I made a general improvement to the program. I realized that if you have segments of a line or polyline that are not at the quadrant angles (0, 90, 180, 270), then you would want to dimension BOTH the Horizontal and the vertical directions. This should still automatically check for CW or CCW Polyline direction. See the attached update. I imagine someone here could probably create a much more elegant solution. If you have one - feel free to add your own version. AD-Automatic Dimension Autocad (4).LSP Edited December 11, 2019 by pkenewell Quote
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.