Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
gc_broach
Posts: 13
Registered: ‎08-11-2009
Message 1 of 5 (282 Views)

Arrowhead toggle

282 Views, 4 Replies
02-08-2011 08:05 AM

Is it possible to create an arrowhead toggle? I found this extension line toggle in this forum but can't figure out how to modify it to do what I want. I want to be able to turn individual arrowheads on and off after the dimension has been created. We do use assocuative dimensions.

 

(defun c:se (/ e el ss dxf dv dvr xdp xds se1 se2 ds do dse1 dse2)
(defun dxf (x l) (cdr (assoc x l)))
(defun dv (dc do / ll cnt)
(setq ll (length do)
cnt 0
)
(while (and (< cnt ll) (/= dc (cdr (nth cnt do))))
(setq cnt (+ cnt 2))
)
(if (< cnt ll) (cdr (nth (1+ cnt) do)))
)
(defun dvr (dc do / ll cnt ret)
(setq ll (length do)
cnt 0
)
(while (< cnt ll)
(if (/= dc (cdr (nth cnt do))) (setq ret (cons (nth (1+ cnt) do) (cons (nth cnt do)
ret))))
(setq cnt (+ cnt 2))
)
(reverse ret)
)
(setq e
(if (setq ss (cadr (ssgetfirst)))
(ssname ss (1- (sslength ss)))
(if (setq e (entsel "\nSelect a dimension: ")) (car e))
)
)
(if (and e (= "DIMENSION" (dxf 0 (setq el (entget e '("ACAD"))))))
(progn
(setq do (cddr (member '(1000 . "DSTYLE") (cdadr (assoc -3 el))))
xdp (reverse (member '(1000 . "DSTYLE") (reverse (cddr (assoc -3 el)))))
xds (member '(1002 . "}") do)
do (reverse (cdr (member '(1002 . "}") (reverse do))))
ds (tblsearch "dimstyle" (dxf 3 el))
dse1 (zerop (dxf 75 ds))
dse2 (zerop (dxf 76 ds))
se1 (cond ((dv 75 do) (zerop (dv 75 do))) (dse1))
se2 (cond ((dv 76 do) (zerop (dv 76 do))) (dse2))
)
(setq xdp (if xdp (append xdp '((1002 . "{"))) '((1000 . "DSTYLE") (1002 . "{"))))
(if (not xds) (setq xds '((1002 . "}"))))
(if (setq se1 (not se1)) (setq se2 (not se2)))
(setq do (dvr 75 do))
(if (/= se1 dse1)
(setq do (cons '(1070 . 75) (cons (cons 1070 (if se1 0 1)) do)))
)
(setq do (dvr 76 do))
(if (/= se2 dse2)
(setq do (cons '(1070 . 76) (cons (cons 1070 (if se2 0 1)) do)))
)
(entmod
(if (assoc -3 el)
(subst (list -3 (cons "ACAD" (append xdp do xds))) (assoc -3 el) el)
(append el (list (list -3 (cons "ACAD" (append xdp do xds)))))
)
)
)
(princ "\nYou must select a dimension")
)
(princ)
)

*Expert Elite*
Kent1Cooper
Posts: 5,370
Registered: ‎09-13-2004
Message 2 of 5 (271 Views)

Re: Arrowhead toggle

02-08-2011 11:20 AM in reply to: gc_broach

gc_broach wrote:

Is it possible to create an arrowhead toggle? I found this extension line toggle in this forum but can't figure out how to modify it to do what I want. I want to be able to turn individual arrowheads on and off after the dimension has been created. ....


That would be done through the Extended Data for the dimension entity, just as the extension-line toggling is.  If the dimension has the default arrowheads for the Dimension Style, then there are no pairs of entries like this, but if it's overridden at either end or both, you'll find a pair of entries like

(1070 . 343) (1005 . "4A277")

for the first-end arrowhead, and another like

(1070 . 344) (1005 . "57")

for the second.

 

I think the "57" may represent using the Style's default, but it might be related to the specific Block, though it doesn't seem to use an actual Block name for any of the choices.  The "4A277" is what it shows when I set that end's arrowhead to None, which I assume is what you mean by turning the arrowhead off.

 

Extension-line suppression is controlled by a 1070 entry [(1070 . 1) to suppress it, (1070 . 0) to show it] immediately following (1070 . 75) for the first extension line, and by one following (1070 . 76) for the second.  The arrowheads are similarly controlled by 1005 entries immediately following (1070 . 343) and ...344).  [Could they make this any more complicated?]  So you ought to be able to use pretty much of the same code to impose the addition of, or a change in, the appropriate 1070/1005 pair of entries for the end you want to toggle.

 

I suspect you would need to add

(1070 . 343) (1005 . "4A277")

to turn the arrowhead off for the first end if arrowheads are normal when you start, because you couldn't change a value that wouldn't be there.  But you'd need to change to that "4A277" if they're not normal when you start, or have ever been changed already.  And similarly with the 344 one for the second end.  And I suspect you would need to change them to "57" to turn the arrowheads back on.  What you should do if having no arrowhead is the default in the Dimension Style, I couldn't say.

 

Once things like that have changed, they seem to remain in the extended data, even after resetting the values to the defaults, and even after getting out of the drawing and back in -- they don't seem to revert to not being there the way they were not before anything was un-defaultized.

Kent Cooper
*Expert Elite*
Kent1Cooper
Posts: 5,370
Registered: ‎09-13-2004
Message 3 of 5 (248 Views)

Re: Arrowhead toggle

02-09-2011 09:57 AM in reply to: gc_broach

gc_broach wrote:

Is it possible to create an arrowhead toggle? I found this extension line toggle in this forum ....


I was curious, because the issue of toggling extension lines has come up before, and I wrote something to do it, so I loaded up the one you posted, and tried it out.  I would describe it as not a "toggle" but a "cycle" function.  You pick anywhere on a dimension with both extension lines on, and it turns one off, then if you keep picking it, it next turns that one back on and the other one off, then both off, then both back on again.  That seems like a pain, when you can get the change you want directly with one pick, instead of cycling through to the right combination.

 

The routine attached to Message 11 on this thread:
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Can-I-toggle/td-p/2332818/page/2

is a real toggle for extension lines.  It finds the one closer to the point where you pick on the dimension, and turns it on if it's off, or off if it's on.  It works in all manner of oddball situations that less sophisticated togglers get confused by -- if you want to get some idea of the complications, check out the discussion on this thread:

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Toggle-Extension-Lines/td-p/2429959/h....

 

Maybe I'll find time to work on adjusting that to toggle the arrowheads instead, but it won't be right away.  Anyone else may feel free to give it a shot if you like.

Kent Cooper
Contributor
gc_broach
Posts: 13
Registered: ‎08-11-2009
Message 4 of 5 (246 Views)

Re: Arrowhead toggle

02-09-2011 10:05 AM in reply to: gc_broach

I agree, I would rather have it work like aiarrowflip just pick near the end you would like to turn off. I am not a good enough programmer. I can only maks simple changes to existing programs or very basic stuff.

*Expert Elite*
Kent1Cooper
Posts: 5,370
Registered: ‎09-13-2004
Message 5 of 5 (221 Views)

Re: Arrowhead toggle

02-10-2011 04:41 AM in reply to: Kent1Cooper

Kent1Cooper wrote:

....extended data....

(1070 . 343) (1005 . "4A277")

for the first-end arrowhead, and ...

(1070 . 344) (1005 . "57")

for the second.

 

I think the "57" may represent using the Style's default, but it might be related to the specific Block, though it doesn't seem to use an actual Block name for any of the choices.  The "4A277" is what it shows when I set that end's arrowhead to None, which I assume is what you mean by turning the arrowhead off.

....


Well, after some experimentation, I find that setting one to None results in varying values, so the 4A277 isn't a constant for that.  The 57 seems to represent our custom arrowhead, not the default generically.

 

I think the solution is going to involve not the entity data or extended data but the VLA Properties Arrowhead1Block & Arrowhead2Block, which use actual Block names.  And the arrowhead defaults for the Dimension Style are found in the 5, 6 & 7 codes from the definition in the Dimstyle table.  [5 if they're both the same, with 6 & 7 being "", or if they're different, 5 is "" and 6 & 7 have the Block names.]

 

So it should be possible to impose None on one to turn it off, and impose the default from the style on it to turn it back on.  But I'm not sure whether one could turn back on an arrowhead that was an override, not the default.

Kent Cooper
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.