Author Topic: Ability to rotate a dimension around an axis and mirror itself if necessary.  (Read 1695 times)

0 Members and 1 Guest are viewing this topic.

Keith Brown

  • Swamp Rat
  • Posts: 601
I am new to trying to program in LISP and need some pointers.  I am not looking for entire code, I don't mind writing it all myself but I have no idea where to start.  I just bought the The Visual LISP Developer's Bible, 2011 Edition from Amazon and that is going to be my training manual but I am a little lost.  I have started programming in vb.net and like that environment but thought I might tackle this issue with lisp.  So here is the problem that I must solve:

I have a dimension in 3D space that dimensions the length of a pipe (Autocad MEP).  I would like the ability to place the dimension on two picked points (pipe ends) and then rotate the dimension around the axis of those two points if needed.  This has the possiblity of creating a dimension that looks mirrored.  For example, a dimension that is rotated around the axis 180 degrees is mirrored.  Rotating the text 180 degrees is not enough to fix the problem.  How i do it manually is to set the UCS to the dimension and then reset the UCS exactly opposite to the current UCS and then draw the dimension.  This will place the text in the correct orientation.  This is where I get lost.

So I have no idea where to start.  I would like to be able to limit the rotation of the dimension to 45, 90, 135, 180, 225, 270, and 315 degrees but to get to that point seems pretty far away.  Is this something I should pursue with LISP or would I be more likely to get a solution using vb.net?  Can you do Jigs in LISP?  I would like to be able to select the first point and then show the dimension as you are selecting the second point.  That way the user could mirror or rotate the text before the selected the second point if it was needed.
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
There's generally 3 ways of going about this in lisp: (1) use lisp as a scripting language calling the relevant commands; (2) modify the object's raw data through the DXF codes; (3) use ActiveX/COM interface to change properties and invoke methods on each object.

(1) is usually where everyone starts, since it's the least amount of learning (you basically need to figure out what commands you'd use).

(2) is where everyone turns when they realize 1 is just too slow and is limited in some respects.

(3) is when you're getting to points where it becomes way too difficult to hack through all the DXF, or when you work on stuff like dynamic blocks / annotative objects.

And then you start getting to points where ADesk hasn't allowed any access from lisp (especially on vertical products) - which is when you start looking into using DotNet.

You're on the right track with the Dim. I'd start out by using 3dRotate and then setting it's UCS. Then I'd start looking at how that changes the dim's DXF values and read up in the help files regarding these DXF's. You might be interested in my old lisp to change a Dim's UCS (though it only works for UCS's rotated around Z - haven't tested it on actual 3d UCS's): http://forums.augi.com/showthread.php?109131-Dimension-UCS-Change

I've gone the DXF route in that code. It might give you a starting point at least.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.