Author Topic: Reassociate dimensions non-associative  (Read 3882 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Reassociate dimensions non-associative
« on: January 29, 2015, 07:30:42 AM »
Hello everyone,
after a long search on the web I found this code:

Code: [Select]
(defun c:ReAss (/ ss i e d pt)
  (if (setq ss (ssget "_:L" '((0 . "DIMENSION"))))
    (repeat (setq i (sslength ss))
      (if
        (and (eq (cdr (assoc 100 (reverse (setq d (entget (setq e (ssname ss (setq i (1- i)))))))))
                 "AcDbAlignedDimension"
             )
             (nentselp (setq pt (trans (mapcar '(lambda (a b) (/ (+ a b) 2.))
                                               (cdr (assoc 13 d))
                                               (cdr (assoc 14 d))
                                       )
                                       0
                                       1
                                )
                       )
             )
        )
         (progn (command "_.dimreassociate" e "" "_S" "_non" pt)
                (while (eq 1 (logand 1 (getvar 'CMDACTIVE))) (command ""))
         )
      )
    )
  )
  (princ)
)


It works well.
However if I replace the first line with

  (if (setq ss (ssget '((0 . "DIMENSION"))))

or with

(if (setq ss (ssget "X" '((0 . "DIMENSION"))))

it does not work.
What is "_:L"?

Thanks in advance

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Reassociate dimensions non-associative
« Reply #1 on: January 29, 2015, 07:35:39 AM »

What is "_:L"?

That is to filter objects on LOCKED layers .

Lupo76

  • Bull Frog
  • Posts: 343
Re: Reassociate dimensions non-associative
« Reply #2 on: January 29, 2015, 08:19:01 AM »
Ok, thanks for the reply. I did not know it.
However I do not understand why with the following code does not work?

Code: [Select]
(if (setq ss (ssget '((0 . "DIMENSION"))))

I noticed with no "_:L" the command (command "_.dimreassociate" .....) emits the error that the selected object is not a line, arc, etc..
I think this happens because the dimension should be associated with lwpolylines.
With (ssget "_:L") the command "_.dimreassociate" succeeds and also recognizes polylines, while without not work.

Any idea?

Lupo76

  • Bull Frog
  • Posts: 343
Re: Reassociate dimensions non-associative
« Reply #3 on: January 31, 2015, 06:42:36 AM »
With a little patience, I analyzed the code better and rewritten based on my habits:

Code: [Select]
(defun RiassociaQuote (selez / n ent1 d pt)
  (setvar "OSMODE" 0)
  (setq n 0)
  (setq ent1 (ssname selez n)) ;nome della prima entità della selezione
  (while (/= ent1 nil)
    (progn
      (if (= (vall 0 ent1) "DIMENSION")
        (progn
          (setq d (entget ent1))
          (setq pt (trans (mapcar '(lambda (a b) (/ (+ a b) 2.0)) (cdr (assoc 13 d))(cdr (assoc 14 d))) 0 1))
         
         
          (if (and
                (or
                  (eq (cdr (assoc 100 (reverse d))) "AcDbAlignedDimension")
                  (eq (cdr (assoc 100 (reverse d))) "AcDbRotatedDimension")
                )
                (nentselp pt)
              )
              (progn
                (command "_.dimreassociate" ent1 "" "_S" "_non" pt)
                (while (eq 1 (logand 1 (getvar 'CMDACTIVE))) (command ""))
              )
          )
        )
      )

      ;--
      (setq n (+ n 1))
      (setq ent1 (ssname selez n)) ;nome dell'oggetto successivo
    )
  )
)

But not always work correctly.
The problem is the following line:

Code: [Select]
(command "_.dimreassociate" ent1 "" "_S" "_non" pt)

In practice, even if the snap is turned off with "_non", the selection of the object through a point (pt), is very influenced by the value of the zoom.
So when in the vicinity of pt there are other nearby objects, is not always selected the correct object.

PS. I assure you that pt passes on a single object, but often are selected nearby objects.
Do you have any idea on how to get around this problem.
I have finished my resources and then ask for help to you.

Thanks in advance.


owenwengerd

  • Bull Frog
  • Posts: 451
Re: Reassociate dimensions non-associative
« Reply #5 on: January 31, 2015, 11:17:34 AM »
In practice, even if the snap is turned off with "_non", the selection of the object through a point (pt), is very influenced by the value of the zoom.
So when in the vicinity of pt there are other nearby objects, is not always selected the correct object.

If you know which object you want, pass the entity name with the point in the same style as the return from (entsel):
(command "_.dimreassociate" ent1 "" "_S" (list entity pt))

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Reassociate dimensions non-associative
« Reply #6 on: January 31, 2015, 11:49:55 AM »
I recognize that code. It was a cadtutor post, if I remember correctly.
Glad you got it working.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Reassociate dimensions non-associative
« Reply #7 on: January 31, 2015, 12:16:12 PM »
If you know which object you want, pass the entity name with the point in the same style as the return from (entsel):
(command "_.dimreassociate" ent1 "" "_S" (list entity pt))
:o

Lupo76

  • Bull Frog
  • Posts: 343
Re: Reassociate dimensions non-associative
« Reply #8 on: February 01, 2015, 11:29:31 AM »
Maybe PickBox = 0  ?

It could be the correct solution.
Unfortunately I now have a more serious problem to be solved and I can not try it right now.
I hope I can try by the end of next week.

Lupo76

  • Bull Frog
  • Posts: 343
Re: Reassociate dimensions non-associative
« Reply #9 on: February 01, 2015, 11:30:34 AM »
In practice, even if the snap is turned off with "_non", the selection of the object through a point (pt), is very influenced by the value of the zoom.
So when in the vicinity of pt there are other nearby objects, is not always selected the correct object.

If you know which object you want, pass the entity name with the point in the same style as the return from (entsel):
(command "_.dimreassociate" ent1 "" "_S" (list entity pt))

Unfortunately I do not know the entity to associate:-(

Lupo76

  • Bull Frog
  • Posts: 343
Re: Reassociate dimensions non-associative
« Reply #10 on: February 05, 2015, 12:00:37 PM »


Lupo76

  • Bull Frog
  • Posts: 343
Re: Reassociate dimensions non-associative
« Reply #12 on: February 06, 2015, 03:32:17 AM »
Unfortunately, I have another problem connected.
The lisp contains the function (command).
Unfortunately I have to use it within a reactor.
In this case, so I can not use:
Code: [Select]
(command "_.dimreassociate" ent1 "" "_S" "_non" pt)
I tried with
Code: [Select]
(vl-cmdf "_.dimreassociate" ent1 "" "_S" "_non" pt)
but even this does not work inside a reactor  :cry: :cry:

Have you any suggestions?

Lupo76

  • Bull Frog
  • Posts: 343
Re: Reassociate dimensions non-associative
« Reply #13 on: February 07, 2015, 01:16:49 PM »
After several days and several attempts I managed to solve the problem by circumventing.
Now my application can work with no associative dimensions  :lmao:

Thank you all for the invaluable assistance  ;-)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Reassociate dimensions non-associative
« Reply #14 on: February 08, 2015, 09:28:12 AM »
...
The lisp contains the function (command).
Unfortunately I have to use it within a reactor.
...
Have you any suggestions?
In such cases you can try using a 'post process':
http://www.theswamp.org/index.php?topic=42826.msg505457#msg505457