Jump to content

Recommended Posts

Posted

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

Posted
22 hours ago, Jim Clayton said:

that it currently is set for "Dim-Aligned".  I need it to be set to "Dim-Linear". 

@BIGAL

Posted

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.

Posted

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

 

Posted

well hell...that's not any good.  Let me keep messing with it.  Maybe I'll stumble across it.  I appreciate the help.

Posted

Would I be overriding "vla-adddimaligned" or does this need to be placed elsewhere.  Please and thank you.

Posted (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 by pkenewell
Posted

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.

Posted

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.

Posted (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 by pkenewell
Posted

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.

Posted
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.

Posted (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 by pkenewell
Posted (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 by pkenewell
New file version
  • Thanks 1
Posted

That's perfect! @pkenewell you're a genius...this is going to save loads of time.  I greatly appreciate all the help.  Thanks again!

 

Posted (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 by pkenewell

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...