TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lupo76 on January 29, 2015, 07:30:42 AM
-
Hello everyone,
after a long search on the web I found this code:
(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
-
What is "_:L"?
That is to filter objects on LOCKED layers .
-
Ok, thanks for the reply. I did not know it.
However I do not understand why with the following code does not work?
(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?
-
With a little patience, I analyzed the code better and rewritten based on my habits:
(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:
(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.
-
Maybe PickBox = 0 ?
-
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))
-
I recognize that code. It was a cadtutor post, if I remember correctly.
Glad you got it working.
-
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
-
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.
-
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:-(
-
Maybe PickBox = 0 ?
It Works! thank you!
-
Maybe PickBox = 0 ?
It Works! thank you!
You welcome. ;D
-
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:
(command "_.dimreassociate" ent1 "" "_S" "_non" pt)
I tried with
(vl-cmdf "_.dimreassociate" ent1 "" "_S" "_non" pt)
but even this does not work inside a reactor :cry: :cry:
Have you any suggestions?
-
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 ;-)
-
...
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