2 dimensions at once

2 dimensions at once

Ajohnson0
Contributor Contributor
1,640 Views
16 Replies
Message 1 of 17

2 dimensions at once

Ajohnson0
Contributor
Contributor

I work in the formwork industry and I have to do dimensioning after I do a layout. I am trying to find a way that would be faster. I basically want to pick 2 points and get a Horizontal and Vertical distance at once. In the pic shown I want to show the location oF the post from the column by click the corner of the column and then the center of the post.

 

 

0 Likes
Accepted solutions (1)
1,641 Views
16 Replies
Replies (16)
Message 2 of 17

Kent1Cooper
Consultant
Consultant

That shouldn't be difficult, using the DIMHORIZONTAL and DIMVERTICAL commands.  But how is the dimension line position to be determined for each?  They're different distances from the "box" defined by the two locations in your image.  Should there be pauses built in for the User to place each?  [Not as much of a time savings....]   To automate the positions, a multiple of the current Dimension Style's text height away from the "box" could work, but could be a problem if your text is always horizontal rather than aligned with the dimension line [imagine if your 7'-8" one had longer text content such as 27'-6 7/8" and its dimension line was closer to the "box" as your 5'-3" one is -- you could get undesirable overlaps].  Automating the positions would probably also require that you always pick the corners in the same order, such as with the corner nearer to the dimension-line sides always picked second.

Kent Cooper, AIA
0 Likes
Message 3 of 17

Ajohnson0
Contributor
Contributor

24" from the center would work for what I need

 

0 Likes
Message 4 of 17

Kent1Cooper
Consultant
Consultant

@Ajohnson0 wrote:

24" from the center would work for what I need


Something like this [minimally tested, and without *error* handling]:

(defun C:DIMVH (/ p1 p2 delta osm); = DIMension Vertical & Horizontal
  (setq
    p1 (getpoint "\nAway-from-dimension-sides corner: ")
    p2 (getcorner p1 "\nDimension-sides opposite corner: ")
    delta (mapcar '- p2 p1)
    osm (getvar 'osmode)
  )
  (setvar 'osmode 0)
  (command
    "_.dimvertical" p1 p2
      (polar p2 (if (minusp (car delta)) pi 0) 24)
    "_.dimhorizontal" p1 p2
      (polar p2 (* pi (if (minusp (cadr delta)) 1.5 0.5)) 24)
  )
  (setvar 'osmode osm)
)

Set the Dimension Style and Layer to what you want used, beforehand.  If desired, the setting of those could also be built into it.

Kent Cooper, AIA
Message 5 of 17

Ajohnson0
Contributor
Contributor

this works very well! thanks! is there anyway I could leave it open? for example if I needed to do multiple dimensions I would like to just keep using the command instead of having to enter it each time? Like in the pic shown

0 Likes
Message 6 of 17

Ajohnson0
Contributor
Contributor

one thing I just came across was occasionally after using the routine it will turn off my snaps when I enter a new command

 

0 Likes
Message 7 of 17

Kent1Cooper
Consultant
Consultant

@Ajohnson0 wrote:

... if I needed to do multiple dimensions I would like to just keep using the command instead of having to enter it each time? ....


That can be worked in, but in the meantime, all you need to do is hit Enter/space to recall it.

Kent Cooper, AIA
0 Likes
Message 8 of 17

Kent1Cooper
Consultant
Consultant

@Ajohnson0 wrote:

one thing I just came across was occasionally after using the routine it will turn off my snaps when I enter a new command


That implies that something went wrong in the running of it before it got to resetting the Osnaps.  I don't see where that could be happening, since everything is automatic in between, and there's no obvious place where something could be missing like a nil variable value or the like.  Do you see any messages?

Kent Cooper, AIA
0 Likes
Message 9 of 17

Ajohnson0
Contributor
Contributor

No error messages on my end, I had a co-worker try it and I didn't mention the O-Snap thing and he ended up having the same error. 

0 Likes
Message 10 of 17

Kent1Cooper
Consultant
Consultant
Accepted solution

As written in Message 4, since it doesn't "exit quietly," you should see a number at the Command line after you use it, which is the OSMODE System Variable value that it reset.  [I do when I run it, and it represents my preferred combination of modes.]  It's what was stored in the 'osm' variable earlier in the routine.

 

If you do see a number, and it's 0, i.e. all Osnap modes off, then presumably it was 0 when you started.  Or if it's greater than 16384, your modes are still set, but Osnapping was suppressed [as with the F3 key] when you started.

 

If you have the problem but then press F3, does your standard combination of modes go into effect again?

 

Or, do you somehow not see a number at the Command line after you run it?

 

Or, did you alter the code in some way?

Kent Cooper, AIA
0 Likes
Message 11 of 17

Ajohnson0
Contributor
Contributor

It is still turning of the O-Snaps. Here is a screen shot of the Command List (prompts). You can see it worked the first time and then the second time around it somehow went to 0. That is when my O-snaps turned off.

0 Likes
Message 12 of 17

Sea-Haven
Mentor
Mentor

All was fine repeated multi times and got 47. Tested in Briscad.

 

 

 

0 Likes
Message 13 of 17

Sea-Haven
Mentor
Mentor

This may be useful.

 

 

0 Likes
Message 14 of 17

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

This may be useful.


Perhaps, but only if you also supply the  Multi Getvals.lsp  routine.  And note several things:  It requires you to pick the lower left corner only  [you can't choose where to start]; it asks for distance values for the edges [presumably you can't pick once at the opposite corner as requested, though without that other code it's hard to say whether there are entry options]; it draws in  the rectangle [not part of the request]; the dimensions always go only to the right and above  [you can't decide where you want them].

Kent Cooper, AIA
0 Likes
Message 15 of 17

Kent1Cooper
Consultant
Consultant

@Ajohnson0 wrote:

It is still turning of the O-Snaps. Here is a screen shot ....



I see the  _u  Undoings in between runnings of the DD command.  Does the same problem occur if you don't Undo before running it again?

 

Could the first  _u  [the one that says  (Lisp expression) GROUP ] be undoing only the resetting of OSMODE?  Does the second one [that says  DD GROUP  ] undo both  Dimensions that the DD command drew, or only one?  If it undoes both, I would think it should undo the whole sequence of things including the setting of OSMODE to 0, but since it wasn't [yet] built with Undo begin/end wrapping around it, I expect not.

 

I'm working on a revision that repeats, and that has the Undo begin/end wrapping and *error* handling -- maybe that will solve it.  But not until Monday.

Kent Cooper, AIA
0 Likes
Message 16 of 17

Sea-Haven
Mentor
Mentor

It was just intended as an example of doing a hor and ver dim to an object, you are right probably not best example.

0 Likes
Message 17 of 17

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... I'm working on a revision that repeats, and that has the Undo begin/end wrapping and *error* handling -- maybe that will solve it.  ....

Something like this:

(vl-load-com); if needed
(defun C:DIMVH (/ *error* doc p1 p2 delta osm)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    ); if
    (setvar 'osmode osm); reset
    (vla-endundomark doc)
    (princ)
  ); defun - *error*
  (vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
  (while (setq p1 (getpoint "\nAway-from-dimension-sides corner or <exit>: "))
    (setq
      p2 (getcorner p1 "\nDimension-sides opposite corner: ")
      delta (mapcar '- p2 p1)
      osm (getvar 'osmode)
    ); setq
    (setvar 'osmode 0)
    (command
      "_.dimvertical" p1 p2
        (polar p2 (if (minusp (car delta)) pi 0) 24)
      "_.dimhorizontal" p1 p2
        (polar p2 (* pi (if (minusp (cadr delta)) 1.5 0.5)) 24)
    ); command
    (setvar 'osmode osm); to again allow using it for locations [if on beforehand]
  ); while
  (vla-endundomark doc)
  (princ)
); defun

It still has the 24-unit dimension-line positioning distance built in -- for general application, it could be made to ask for that distance, or base it on something like the current Dimension Style's text height.

Kent Cooper, AIA
0 Likes