Author Topic: Challenge: Dim Reactor  (Read 8478 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Challenge: Dim Reactor
« on: August 20, 2008, 04:20:00 PM »
Those of us that use Architectural units typically dimension with feet and inches.
Using smaller dimensions, less than 2 feet, it is desirable in some cases to have the dimension in Inches only.
Seeing a comment on another forum gave me the idea that a reactor might be constructed to change the
dimension over ride to display inches and add the inch character as the suffix.

So the challenge would be to create a reactor to do just that for any command that created a dimension or
edited a dimension. There should be a user changeable threshold for the reactor to switch the dimension to inches
or back to feet & inches. There should also be a list of user supplied Dim Styles that would filter for allowable
Dim Styles. This would prevent some styles from being modified.

I would say that this is probably an advanced level challenge.
Anyone interested?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #1 on: August 20, 2008, 04:26:39 PM »
« Last Edit: August 20, 2008, 04:41:19 PM by LE »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge: Dim Reactor
« Reply #2 on: August 20, 2008, 04:46:17 PM »
Yes Luis, I did not see that code.

PS I won't be able to test it tonight as I'm out till late.
« Last Edit: August 20, 2008, 04:50:19 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #3 on: August 20, 2008, 04:59:24 PM »
Yes Luis, I did not see that code.

PS I won't be able to test it tonight as I'm out till late.



Alan,

Hope that helps... :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge: Dim Reactor
« Reply #4 on: August 20, 2008, 07:50:13 PM »
Just got in, that will likely do just fine.
I did not plan on writing the code I just though it would be a good challenge.
I'm hoping some folks may have an intrest in the writing of the code.
« Last Edit: August 21, 2008, 09:15:20 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge: Dim Reactor
« Reply #5 on: August 21, 2008, 09:20:42 AM »
See attached a copy of the lisp with the variables corrected as they were wrong type. Luis pointed this out.

Works well Luis, but there are some items that don't match my requirements.
I'm not asking Luis to alter the lisp. Just seeing if someone else wants to give it a go.

Routine does not alter the Dimension if it is modified, only when created.
Routine does not honer specific Dim Styles, works on all Dim Styles.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #6 on: August 21, 2008, 09:51:45 AM »
Just got in, that will likely do just fine.
I did not plan on writing the code I just though it would be a good challenge.
I'm hoping some folks may have an intrest in the writing of the code.

That code can be use as a start.... :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge: Dim Reactor
« Reply #7 on: August 21, 2008, 09:57:29 AM »
Yes, you did the hard part. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #8 on: August 21, 2008, 10:12:18 AM »
Yes, you did the hard part. 8-)

:)

Quote
Routine does not alter the Dimension if it is modified, only when created.
Routine does not honer specific Dim Styles, works on all Dim Styles.

Those two can be very easy to add..... (that's what I miss from lisp)

Let's see/wait if any other swamper come up with a solution...  :mrgreen:
« Last Edit: August 21, 2008, 12:52:05 PM by LE »

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #9 on: August 21, 2008, 04:41:35 PM »
The problem, is going to be in the "modified" event - owner is not open for write... and has to be included in a list and later do the updates from probably the Regen command (at the commandended event)... as far I recall

POCKETS

  • Guest
Re: Challenge: Dim Reactor
« Reply #10 on: August 21, 2008, 05:27:57 PM »
Cab,
I downloaded your fractdims.lsp but I can't get it to work.  I am looking for a "defun c" but there doesn't seem to be one.  Is there another way to get fractdims.lsp to work?   :|
Pockets

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge: Dim Reactor
« Reply #11 on: August 21, 2008, 05:30:41 PM »
LE (luis) wrote the routine. It is a reactor, so just load it.
When you create a dimension < 48" it should show inches.
If the dim is > 48" it should show as set up in the Dim Style.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #12 on: August 21, 2008, 05:46:22 PM »
Cab,
I downloaded your fractdims.lsp but I can't get it to work.  I am looking for a "defun c" but there doesn't seem to be one.  Is there another way to get fractdims.lsp to work?   :|
Pockets

As Alan already mentioned.... and you can read the settings on top of the file ie:

Quote
;; variables
(setq auto_fract T) ;; ON === By simple changing this to nil (setq auto_fract nil) it will turn off the feature (not the reactor)
(setq min_dim_tol "0.25")
(setq max_dim_tol "48.0")
(setq dim_radius_suffix "\"")
(setq dim_radius_prefix "R=")
(setq dimstyles (list "DIM-1" "DIM-48" "DIM-96" "DIM-32")) N/A

Change the variables to suit your needs... hth

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge: Dim Reactor
« Reply #13 on: August 21, 2008, 06:03:37 PM »
Here is a modified version.
If you stretch the dimension to <=48" it will change to inches.
But stretching the other way does not work yet. I'm pondering what to do when there are existing xdata overrides present.
The current routine overwrites existing xdata.

This is a test release.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #14 on: August 21, 2008, 07:00:54 PM »
Here is a modified version.
If you stretch the dimension to <=48" it will change to inches.
But stretching the other way does not work yet. I'm pondering what to do when there are existing xdata overrides present.
The current routine overwrites existing xdata.

This is a test release.

Alan,

have a look at this update, it works here back and forward, and even with matchprop too... please ignore the code enchilada I just did.

Notes:
1. I did not understood the cond usage the part "AcDbRadialDimension" - I thought that was taking care on "DIMRADIUS" - me might wrong.

2. I reuse my previous if's calls

3. Added a new function to change the xdata, but this can be place on a single function, merge fractional-dim and fractional-dim-arch

4. hth

5. almost forgot.... so where are the swamp lispers ?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Challenge: Dim Reactor
« Reply #15 on: August 21, 2008, 07:43:08 PM »
5. almost forgot.... so where are the swamp lispers ?

I was looking at one way while trying to get my work done, need to keep my job and all.  I haven't figured it out yet, but I think it will work sweet when I get it there.  Hopefully tomorrow.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Challenge: Dim Reactor
« Reply #16 on: August 21, 2008, 07:49:04 PM »

5. almost forgot.... so where are the swamp lispers ?

Some of us have real work that needs doing ...

and other languages to study  :-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #17 on: August 21, 2008, 07:52:40 PM »
I only asked where there were.....  :-P

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Challenge: Dim Reactor
« Reply #18 on: August 21, 2008, 08:30:31 PM »
Luis,
I decided to make a major revision in the commandended routine.

See if you can break it.

<edit: renamed lisp file>
« Last Edit: August 22, 2008, 11:58:33 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #19 on: August 21, 2008, 10:25:37 PM »
Luis,
I decided to make a major revision in the commandended routine.

See if you can break it.


That's the right way..... Cheers!

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Challenge: Dim Reactor
« Reply #20 on: August 22, 2008, 07:10:43 AM »
so where are the swamp lispers ?

Working.......  :|
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

Chuck Gabriel

  • Guest
Re: Challenge: Dim Reactor
« Reply #21 on: August 22, 2008, 07:12:39 AM »
Some of us have real work that needs doing ...

Get your priorities straight Kerry. :-P

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Challenge: Dim Reactor
« Reply #22 on: August 22, 2008, 06:03:48 PM »
Here is one that seems to be working.  It has two variables that you can control which dims get edited.  There is the 'MinLength' and the 'IgnoreDimStyleList'.  Let me know.  I know if can be cleaned up a bit, but for now it works.   :-D

Code: [Select]
(or
    GlbVarReactObjectAdded
    (setq GlbVarReactObjectAdded (vlr-acdb-reactor "DimObjectReactor" '((:vlr-objectAppended . ObjectAppenedReact))))
)
(defun ObjectAppenedReact (react objList / CorrectionList EntData tempList tempSubList tempList2)
   
    (setq CorrectionList
        (list
            -3
            (list
                "ACAD"
                '(1000 . "DSTYLE")
                '(1002 . "{")
                '(1070 . 3)
                '(1000 . "\"")
                '(1070 . 277)
                '(1070 . 2)
                '(1002 . "}")
            )
        )
    )
    (foreach i objList
        (if
            (and
                (equal (type i) 'ENAME)
                (= (cdr (assoc 0 (setq EntData (entget i '("*"))))) "DIMENSION")
                (not (member (cdr (assoc 3 EntData)) IgnoreDimStyleList))
            )
            (progn
                (if (< (cdr (assoc 42 EntData)) MinLength)
                    (if (setq tempList (assoc -3 EntData))
                        (if (setq tempSubList (assoc (caadr CorrectionList) (cdr tempList)))
                            (if (not (equal (cadr CorrectionList) tempSubList))
                                (entmod
                                    (subst
                                        (subst (cadr CorrectionList) tempSubList tempList)
                                        tempList
                                        EntData
                                    )
                                )
                            )
                            (entmod (subst (cons -3 (append (cadr tempList) (cadr CorrectionList))) tempList EntData))
                        )
                        (entmod (append EntData (list CorrectionList)))
                    )
                    (if (setq tempList (assoc -3 EntData))
                        (progn
                            (foreach i (cdr tempList)
                                (if (equal (cadr CorrectionList) i)
                                    (setq tempList2 (cons (list (car i)) tempList2))
                                    (setq tempList2 (cons i tempList2))
                                )
                            )
                            (entmod (subst (cons -3 (reverse tempList2)) tempList EntData))
                        )
                    )
                )
                (if react
                    (vlr-pers
                        (vlr-object-reactor
                            (list (vlax-ename->vla-object i))
                            "DimObjectReactor"
                            '(
                                (:vlr-objectClosed . ObjectModifiedDone)
                                (:vlr-erased . ObjectEraseReactor)
                            )
                        )
                    )
                )
            )
        )
    )
    (and
        GlbVarDimReactCommandEnded
        (vlr-remove GlbVarDimReactCommandEnded)
    )
    (setq GlbVarDimReactCommandEnded nil)
    (setq GlbVarDimReactEntList nil)
    (princ)
)
(defun ObjectModifiedDone (ownObj react tempList)
   
    (setq GlbVarDimReactEntList (cons (vlax-vla-object->ename ownObj) GlbVarDimReactEntList))
    (or
        GlbVarDimReactCommandEnded
        (setq GlbVarDimReactCommandEnded (vlr-command-reactor "tempDimReactCommandEnded" '((:vlr-commandEnded . DimReactCommandEnded))))
    )
    (princ)
)
(defun DimReactCommandEnded (react cmdNames)
   
    (foreach i GlbVarDimReactEntList
        (ObjectAppenedReact nil (list i))
    )
    (princ)
)
(defun ObjectEraseReactor (Obj React NotSure)
   
    (vlr-pers-release React)
    (vlr-remove React)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

whdjr

  • Guest
Re: Challenge: Dim Reactor
« Reply #23 on: September 24, 2008, 08:04:47 AM »
so where are the swamp lispers ?
Some of us have no clue about reactors.  :-(

Alan Cullen

  • Guest
Re: Challenge: Dim Reactor
« Reply #24 on: September 24, 2008, 08:44:01 AM »
Hey...I'm a Swamp Lisper....

What is a reactor?

Sorry...I was asleep that day.

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #25 on: September 24, 2008, 09:34:13 AM »
so where are the swamp lispers ?
Some of us have no clue about reactors.  :-(

:)

no problema, it was just a 'tag' to get more attention to this thread/topic.

i had a lot of clues, but most of them are now lost... there are many samples posted here 'about reactors'

Spike Wilbury

  • Guest
Re: Challenge: Dim Reactor
« Reply #26 on: September 24, 2008, 09:49:21 AM »
What is a reactor?

many autocad commands are made with reactors, like leaders, dimensions, etc. to mention a few... with the intro of vital lisp (later renamed to visual lisp) reactors were available for autolisp to make more intelligent alike routines... in example the ability to place automatic dimensions on one or multiple entities, right after a modification or when an specific command ended, or right before closing a drawing to be able to make last corrections before closing it,  etc. etc etc.

now, there are the 'fields' objects, so many things can be used with these objects...

hth.