Author Topic: Question 30 goes here  (Read 36499 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Re: Question 30 goes here
« Reply #30 on: September 16, 2005, 05:49:58 PM »
It is actually a single line of code.... and a use of a visual lisp function with a T on it...

LE

  • Guest
Re: Question 30 goes here
« Reply #31 on: September 16, 2005, 05:52:40 PM »
I begin using this approach, for my routines with reactors and like the ability to load the callbacks per drawing.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question 30 goes here
« Reply #32 on: September 16, 2005, 06:02:39 PM »
If I was to try with VLisp, first I'd look at

vlax-ldata

and

vlax-add-cmd

Nice Problem Luis,
kwb
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.

LE

  • Guest
Re: Question 30 goes here
« Reply #33 on: September 16, 2005, 06:04:16 PM »
If I was to try with VLisp, first I'd look at

vlax-ldata


Hey.... it is because you are using the VLX..... and saw the message at loading no?.... hehe

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question 30 goes here
« Reply #34 on: September 16, 2005, 06:05:34 PM »
Haven't tried yet Luis, Still making my first morning coffee .. :)
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question 30 goes here
« Reply #35 on: September 16, 2005, 06:08:26 PM »
but I know a little about data persistance, so that headed me in that direction ...
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.

LE

  • Guest
Re: Question 30 goes here
« Reply #36 on: September 16, 2005, 06:10:43 PM »
Very good guess ... sir!

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Question 30 goes here
« Reply #37 on: September 16, 2005, 06:53:46 PM »
Ok, uncle.

I know you use  vlax-ldata-put to put the raw data in:

Code: [Select]
(vlax-ldata-put
    "SmartyPants"
    "hello$stickto_free_version"
    "(&VLO-C lisplet-permanent-data-handle hello"
)

But I couldn't register it to execute on startup (the above assumed a lisp file in the same directory as the file named hello.lsp).

So ... I examined the data and what appeared different was the flag value associated with group 91. In my non functioning data it had a value of 46 instead of 49. I tried brute force entmodding and it wouldn't take, so I tried a hacker's approach: make the data from scratch and mod to suit (ugly coding, forgive me):

Code: [Select]
(defun FooYoo ( lispPath / foo1 foo2 )

    (defun *error* (x) (vl-bt))

    (defun foo1 ( dict dictnametoadd )
        (cond
            (   
                (cdr
                    (assoc -1
                        (dictSearch
                            dict
                            dictnametoadd
                        )
                    )   
                )
            )
            (   (DictAdd dict dictnametoadd
                    (EntmakeX
                       '(   (0 . "DICTIONARY")
                            (100 . "AcDbDictionary")
                        )
                    )
                )   
            )   
        )   
    )
   
    (defun foo2 ( dict dictname lispName / ename ename2 data )
        (DictAdd dict dictname
            (setq ename2
                (EntmakeX
                    (list
                       '(0 . "DICTIONARY")
                       '(100 . "AcDbDictionary")
                       '(280 . 0)
                       '(281 . 1)
                        (cons 3                   
                            (strcat
                                lispName
                                "$stickto_free_version"
                            )                   
                        )
                        (cons 350
                            (setq ename
                                (entmakex
                                    (list
                                       '(0   . "VLO-VL")
                                       '(100 . "vlo_VL")
                                       '(90  .  -64512)
                                       '(91  .  49)
                                       '(92  .  0)
                                        (cons 300
                                            (strcat
                                                "(&VLO-C "
                                                "lisplet-permanent-data-handle "
                                                "\""
                                                lispName                         
                                                "\")"
                                            )   
                                        )
                                    )
                                )
                            )   
                        )
                    )   
                )
            )   
        )
           
        (setq data
            (subst
                (cons 330 ename2)
                (assoc 330
                    (setq data
                        (entget ename)
                    )
                )
                data
            )   
        )
       
        (entmod
            (append
                (setq head
                    (reverse
                        (member
                            (assoc 5 data)
                            (reverse data)
                        )
                    )
                )
                (list
                   '(102 . "{ACAD_REACTORS")
                    (cons 330 ename2)
                   '(102 . "}")
                )
                (member (assoc 330 data) data)
            )   
        )
       
        (entmod
            (subst
               '(91 . 49)
                (assoc 91
                    (setq data
                        (entget ename)
                    )
                )
                data
            )   
        )
           
    )
   
    (foo2
        (namedObjdict)
        "SmartyPants"
        (vl-filename-base lispPath)
    )
   
    (princ)

)

(FooYoo "hello")

Makes the very same data, and it will persist but damn, the 91 flag value refuses to be modded and it won't run on startup.

The Main dictionary (look for SmartyPants dictionary item) --

Code: [Select]
-1    <Entity name: 7ef70c60>
0     DICTIONARY
330   <Entity name: 0>
5     C
100   AcDbDictionary
280   0
281   1
3     ACAD_COLOR
350   <Entity name: 7ef70e18>
3     ACAD_GROUP
350   <Entity name: 7ef70c68>
3     ACAD_LAYOUT
350   <Entity name: 7ef70cd0>
3     ACAD_MATERIAL
350   <Entity name: 7ef70e10>
3     ACAD_MLINESTYLE
350   <Entity name: 7ef70cb8>
3     ACAD_PLOTSETTINGS
350   <Entity name: 7ef70cc8>
3     ACAD_PLOTSTYLENAME
350   <Entity name: 7ef70c70>
3     ACAD_TABLESTYLE
350   <Entity name: 7ef70e70>
3     AcDbVariableDictionary
350   <Entity name: 7ef70db0>
3     SmartyPants  <=  Hello !!!!!!!!!!!!!!!!
350   <Entity name: 7ef70ea0>

The SmartyPants dictionary object:

Code: [Select]
-1    <Entity name: 7ef70ea0>
0     DICTIONARY
5     8C
102   {ACAD_REACTORS
330   <Entity name: 7ef70c60>
102   }
330   <Entity name: 7ef70c60>
100   AcDbDictionary
280   0
281   1
3     hello$stickto_free_version
350   <Entity name: 7ef70e98>

The VLO-VL object entry (child of the dictionary object above).

Code: [Select]
-1    <Entity name: 7ef70e98>
0     VLO-VL
5     8B
102   {ACAD_REACTORS
330   <Entity name: 7ef70ea0>
102   }
330   <Entity name: 7ef70ea0>
100   vlo_VL
90    -64512
91    46  <==  bastard value, should be 49
92    0
300   (&VLO-C lisplet-permanent-data-handle "hello")

-- but I got this close.

So ... let me out of my misery. Just kidding, I enjoyed the hacking.

;)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question 30 goes here
« Reply #38 on: September 16, 2005, 07:39:02 PM »
I could see myself spending the day on this and NOT solving it either..

I'm miserable too ...
 :cry:
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Question 30 goes here
« Reply #39 on: September 16, 2005, 07:49:36 PM »
This is cruel .. Is the sun still up in San Diego .. ?

Luis is probably having a couple of beers and laughing to himself ...  :-D
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.

Bob Wahr

  • Guest
Re: Question 30 goes here
« Reply #40 on: September 16, 2005, 07:55:44 PM »
Let's see...Luis will tell me I'm wrong but before he does I will disagree with him.  As he didn't state lisp routine in the question, I will answer as if it were a VBA routine.  type VBAMAN, select the routine, click EMBED.  It will load the next time the drawring is opened.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Question 30 goes here
« Reply #41 on: September 16, 2005, 08:30:02 PM »
Ooh I'm gettin so close ...

private name space lisp and --

Code: [Select]
(vlax-ldata-put
    "smartypants"
    "hello"
    nil
    t
)

It's not firing yet but the data is looking better ...

/refuse to give up.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Question 30 goes here
« Reply #42 on: September 16, 2005, 08:49:59 PM »
Ok. If I use this statement --

Code: [Select]
(vlax-ldata-put
    "MyDictionary"
    "MyFunction"
    nil
    t
)

Compile to a seperate namespace vlx named Hacker.vlx, and subsequently load that into a drawing, we get these entries --

Dictionary in NamedObjDict:

Code: [Select]
-1    <Entity name: 7ef70c60>
0     DICTIONARY
330   <Entity name: 0>
5     C
100   AcDbDictionary
280   0
281   1
;;  deleted crud I don't care about
3     MyDictionary
350   <Entity name: 7ef70e98>

Child Dictionary:

Code: [Select]
-1    <Entity name: 7ef70e98>
0     DICTIONARY
5     8B
102   {ACAD_REACTORS
330   <Entity name: 7ef70c60>
102   }
330   <Entity name: 7ef70c60>
100   AcDbDictionary
280   0
281   1
3     Hacker$MyFunction
350   <Entity name: 7ef70ed8>

VLO-VL Object

Code: [Select]
-1    <Entity name: 7ef70ed8>
0     VLO-VL
5     93
102   {ACAD_REACTORS
330   <Entity name: 7ef70e98>
102   }
330   <Entity name: 7ef70e98>
100   vlo_VL
90    -64512
91    52
92    0
300   (&VLO-C lisplet-permanent-data-handle "Hacker")

Saga continues ...

:evil:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Question 30 goes here
« Reply #43 on: September 16, 2005, 09:20:20 PM »
Ok. I can get it to work, but the function is firing twice, so I have to place some kind of flag so it recognizes it's already been run once.

:evil:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

LE

  • Guest
Re: Question 30 goes here
« Reply #44 on: September 16, 2005, 09:42:07 PM »
Michael,

Very impress of all your effort... all we need to do is to place on top of our lisp file a call like:

Code: [Select]
(vl-load-com)

(vlax-ldata-put "reactorswiz" "stickto_free_version" nil t)

(alert "this is only a test")

(defun C:TST  ()
  (alert
    "I can be self loaded if you save the drawing\nAnd the next time you open it I will be back"))

Then make a protected separate namespace VLX, have our vlx place in the same folder as our drawing, load the vlx and saved the drawing and that's it....

Have fun!
Luis.

Kerry... Beers will wait for tomorrow, we are going for a wedding in Mexicali and the sun there is really something....