TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Mark on September 16, 2005, 01:21:39 PM

Title: Question 30 goes here
Post by: Mark on September 16, 2005, 01:21:39 PM
Quote from: LE
How to load a routine without having it being part of a acaddoc.lsp, acad.lsp, not inside of the suite, not part of any startup, not even being saved inside of any support folder of autocad.

The routine will be loaded only if exist and still is inside of the original folder location, the user will need to load the routine from there, called or not the routine command and after that, save it, and the next time the drawing session is open it will call the routine to be loaded.

How do you enable that?
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 01:37:44 PM
Not sure if I fully comprehend the question, but it sounds to me like a round about way of referring to mnl files.

/guess
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 01:41:32 PM
Not sure if I fully comprehend the question, but it sounds to me like a round about way of referring to mnl files.

/guess

Not even inside of an MNL

Here are the steps:

1. Load the routine from any where
2. Saved the drawing
3. Open that drawing and the routine is available, without being load from any other means just by itself...

And no reactors too.

HTH
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 01:44:23 PM
Ah, you mean persistant reactors (evil). Thanks for the hints.
Title: Re: Question 30 goes here
Post by: deegeecees on September 16, 2005, 01:44:33 PM
Well, when somebody DOES answer this one, I may change the way I do things around here.

Edit: I did see that in the Dev. Help files a while back, but never persued it. I have thought of some apps that will make use of something like this. I think I'll persue this now.  :ugly:

Re-edit: OK, no persistant reactors, check.  :oops:
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 01:46:46 PM
Ah, you mean persistant reactors (evil). Thanks for the hints.

No persistant reactors too...

Just by itself... on every drawing the routine was used.....
Title: Re: Question 30 goes here
Post by: whdjr on September 16, 2005, 01:47:33 PM
Well number one is easy just include the entire path in the load statement.

(load "Y:\\Common\\AUTOLISP\\ad.lsp)

Getting it to reload is trickier if you don't add it any of the files you mentioned.

Or is there a secret sysvar we haven't heard about yet. :pissed:
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 01:49:55 PM
Well number one is easy just include the entire path in the load statement.

(load "Y:\\Common\\AUTOLISP\\ad.lsp)

Getting it to reload is trickier if you don't add it any of the files you mentioned.

Or is there a secret sysvar we haven't heard about yet. :pissed:

No.... nothing that has to do with any normal way we all know, it is a secret way... that is why the question.... hehe
Title: Re: Question 30 goes here
Post by: whdjr on September 16, 2005, 01:50:35 PM
How about via a script file? :realmad:
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 01:51:04 PM
Well lol, I think you've a dandy of a question 'cause I dunno.

:-D
Title: Re: Question 30 goes here
Post by: whdjr on September 16, 2005, 01:54:16 PM
I GOT IT!!! :mrgreen:

How about loading it via a field in a drawing.
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 01:54:22 PM
Hey Luis wait awhile before posting the answer, we've some friends that are probably into rem sleep right now that would likely enjoy anteing up an answer.
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 01:54:52 PM
How about via a script file? :realmad:

That is a normal way.... is something else.... and it is very efective, the only condition is that the drawing would look if the routine was loaded and tried to call it, every time the drawing session is opened... and of course if the routine file exists... if not if will simple show a message, saying something.... hehe
Title: Re: Question 30 goes here
Post by: deegeecees on September 16, 2005, 01:56:43 PM
Yous hadn't awta upset the Don. Make good wit da ansa or Rocko n da boyz are gonna hafta do reconstructive surgery on ya kneecaps  :pissed: :pissed: :pissed: :pissed: :pissed: :pissed: :pissed: :pissed: :pissed:
Title: Re: Question 30 goes here
Post by: whdjr on September 16, 2005, 01:57:21 PM
Hey Luis wait awhile before posting the answer, we've some friends that are probably into rem sleep right now that would likely enjoy anteing up an answer.

If you don't want to post it yet that's fine but if I am close please PM me.  If I am way off base then don't worry about it.
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 01:58:51 PM
<cough> Hyperlink.
Title: Re: Question 30 goes here
Post by: ronjonp on September 16, 2005, 02:00:11 PM
Looked at the documentation a little closer and found this http://www.theswamp.org/screens/ronjonp/clue.htm
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 02:01:48 PM
If you don't want to post it yet that's fine but if I am close please PM me.  If I am way off base then don't worry about it.

Way off..... sorry
Title: Re: Question 30 goes here
Post by: whdjr on September 16, 2005, 02:01:57 PM
Looked at the documentation a little closer and found this http://www.theswamp.org/screens/ronjonp/clue.htm
:lmao:

not

 :pissed:
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 02:03:01 PM
<cough> Hyperlink.

Nope....
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 02:03:58 PM
(http://www.theswamp.org/screens/mp/404.png)
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 03:26:13 PM
Ok,

Here is a vlx file to test this, after that I will post the open source.

Please place the vlx in the same folder with your drawing and load it.

1. Call the command TST
2. Save the drawing and open it again
3. What happen?
4. Is the TST command available?
5. Look on the APPLOAD list and see if the SELFLOAD.VLX is there?
Title: Re: Question 30 goes here
Post by: Sdoman on September 16, 2005, 03:27:14 PM
Does the soution have to do with editing the AutoCAD registry?  I thought I read something about that somewhere...Don't know where.
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 03:34:19 PM
Please do the test on a new drawing... or make a backup first.....
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 03:40:35 PM
<cough>

(&VLO-C lisplet-permanent-data-handle "selfload")
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 05:30:32 PM
Argggg ... I'm this close to crackin' this nut.

 :evil:
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 05:39:22 PM
Argggg ... I'm this close to crackin' this nut.

 :evil:

What do you think Michael, is this worth or not..... ? or is a mickey-mouse....
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 05:43:04 PM
It's fun crackin' it.

VLO-VL objects, lol, who knew.

Weirdness: '(0   . "VLO-VL") yet '(100 . "vlo_VL") ...

:)
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 05:47:36 PM
It is time to post the code?....
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 05:47:43 PM
PLEASE DON'T POST ANY CODE YET LUIS.

:)
Title: Re: Question 30 goes here
Post by: LE 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...
Title: Re: Question 30 goes here
Post by: LE 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.
Title: Re: Question 30 goes here
Post by: Kerry 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
Title: Re: Question 30 goes here
Post by: LE 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
Title: Re: Question 30 goes here
Post by: Kerry on September 16, 2005, 06:05:34 PM
Haven't tried yet Luis, Still making my first morning coffee .. :)
Title: Re: Question 30 goes here
Post by: Kerry on September 16, 2005, 06:08:26 PM
but I know a little about data persistance, so that headed me in that direction ...
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 06:10:43 PM
Very good guess ... sir!
Title: Re: Question 30 goes here
Post by: MP 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.

;)
Title: Re: Question 30 goes here
Post by: Kerry 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:
Title: Re: Question 30 goes here
Post by: Kerry 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
Title: Re: Question 30 goes here
Post by: Bob Wahr 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.
Title: Re: Question 30 goes here
Post by: MP 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.
Title: Re: Question 30 goes here
Post by: MP 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:
Title: Re: Question 30 goes here
Post by: MP 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:
Title: Re: Question 30 goes here
Post by: LE 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....
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 09:46:28 PM
And.... I found that by reading "vlr-pers-dictname" and after seeing this: vlr-reactor.getdictkey - some few years ago....

Now, what would be the conclusion?

Good
Bad
Does not matter

Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 09:53:04 PM
And.... I found that by reading "vlr-pers-dictname" and after seeing this: vlr-reactor.getdictkey - some few years ago....
Pays to RTFM.

:)

Quote
Now, what would be the conclusion?

Good
Bad
Does not matter

None of the above: Very Interesting indeed, thanks for the trip.

:)
Title: Re: Question 30 goes here
Post by: Kerry on September 16, 2005, 10:00:16 PM
conclusion :
Really Interesting !!
I could see it being abused, but then, so can almost anything.

Right now I can thing of a couple of neat uses for this.

It would be fairly simple to write a removal tool, yes ??

Hope I can make some time next week to play.

Thanks Luis and Good Effort Michael.

.. back to the grindstone ..
kwb



Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 10:08:30 PM
It would be fairly simple to write a removal tool, yes ??

By whom?
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 10:15:55 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.

:-)

Sorry Bob,

No dark side ... forgot to mention that was just with the lispy stuff.
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 10:18:50 PM
<Festus> Simple entdel on that thar dictionary varmit blows it into smithereens ... </Festus>
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 10:35:14 PM
<Festus> Simple entdel on that thar dictionary varmit blows it into smithereens ... </Festus>
Did you check if this is kaput.... too?

Opening an AutoCAD 2004 format file.
Regenerating model.
Restoring Ldata-> <<<<------ this one after deleting....
Title: Re: Question 30 goes here
Post by: Kerry on September 16, 2005, 10:35:42 PM
Quote
By whom?

You'd just have to know what to look for ...

(massoc 3 (entget (namedobjdict)))

("ACAD_COLOR" "ACAD_GROUP"
              "ACAD_LAYOUT"
              "ACAD_MATERIAL"
              "ACAD_MLINESTYLE"
              "ACAD_PLOTSETTINGS"
              "ACAD_PLOTSTYLENAME"
              "ACAD_TABLESTYLE"
              "AcDbVariableDictionary"
              "reactorswiz"
)


.. and know how to blow it up ..
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 10:40:17 PM
<Festus> Simple entdel on that thar dictionary varmit blows it into smithereens ... </Festus>
Did you check if this is kaput.... too?

Opening an AutoCAD 2004 format file.
Regenerating model.
Restoring Ldata-> <<<<------ this one after deleting....

Yep, varmit be gone, just entdel inside out.
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 10:40:48 PM
Quote
By whom?

You'd just have to know what to look for ...

(massoc 3 (entget (namedobjdict)))

("ACAD_COLOR" "ACAD_GROUP"
              "ACAD_LAYOUT"
              "ACAD_MATERIAL"
              "ACAD_MLINESTYLE"
              "ACAD_PLOTSETTINGS"
              "ACAD_PLOTSTYLENAME"
              "ACAD_TABLESTYLE"
              "AcDbVariableDictionary"
              "reactorswiz"
)


.. and know how to blow it up ..


OK, please do a test by deleting the dictionary.... look again into the entget... is not there no?.... now save the drawing and open it again.... is back or not?.... remember that the VLX must be on the same folder as the drawing
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 10:43:09 PM
Like I said, entdel inside out: kill the vlo-vl object then its dictionary. Bye!
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 10:51:01 PM
Like I said, entdel inside out: kill the vlo-vl object then its dictionary. Bye!
OK OK.... I did not read your post...... need glasses and more english classes.....
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 10:52:01 PM
OK OK.... I did not read your post...... need glasses and more english classes.....

No prob, me too.

:P
Title: Re: Question 30 goes here
Post by: Kerry on September 16, 2005, 11:08:23 PM
This IS fun, but I have to get back to WORK guys ..

Have a couple of beers tomorrow Luis ..


Code: [Select]
(setq dictionaries (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
 
(vlax-for obj dictionaries
  (if (vlax-property-available-p obj 'Name)
    (if (= (vla-get-name obj) "reactorswiz")
      (setq Whizzy obj)
    )
  )
)


;; //////

Code: [Select]
(vlax-dump-object Whizzy)
; IAcadDictionary: A container object for storing and retrieving objects
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00b9d604>
;   Count (RO) = 1
;   Document (RO) = #<VLA-OBJECT IAcadDocument 062744e0>
;   Handle (RO) = "111"
;   HasExtensionDictionary (RO) = 0
;   Name = "reactorswiz"
;   ObjectID (RO) = 2130194696
;   ObjectName (RO) = "AcDbDictionary"
;   OwnerID (RO) = 2130189408

;;//
Code: [Select]
(vlax-dump-object (vla-item Whizzy 0))

; IAcadObject: The standard interface for a basic AutoCAD object
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00b9d604>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 062744e0>
;   Handle (RO) = "119"
;   HasExtensionDictionary (RO) = 0
;   ObjectID (RO) = 2130194760
;   ObjectName (RO) = "vlo_VL"
;   OwnerID (RO) = 2130194696
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 11:09:05 PM
I want to thank you Luis, that was a most enjoyable challenge! I think the last time I had that much hacking fun is when I cracked the AutoCAD "student version" flag couple years back.

 :evil:
Title: Re: Question 30 goes here
Post by: LE on September 16, 2005, 11:14:28 PM
I want to thank you Luis, that was a most enjoyable challenge! I think the last time I had that much hacking fun is when I cracked the AutoCAD "student version" flag couple years back.

 :evil:

 :kewl:

The walls can hear...... shhhhhhhhhh   hehe

Yes.... there are some other stuff hidding.... waiting to be exposed....
Title: Re: Question 30 goes here
Post by: MP on September 16, 2005, 11:24:02 PM
I want to thank you Luis, that was a most enjoyable challenge! I think the last time I had that much hacking fun is when I cracked the AutoCAD "student version" flag couple years back.

 :evil:

 :kewl:

The walls can hear...... shhhhhhhhhh hehe

It's a matter of public record (on the desk's news server at one time). I informed Autodesk personal privately how easy it was to crack. I've never shared the info with anyone except Mr. Wengerd, nor have I ever un-edumacated any drawings. I needed to be assured we weren't getting any crap from outside sources that would corrupt our drawings, so I wrote my own utility to detect student drawings before any damage could be done. Necessity being the mother of ...

:)
Title: Re: Question 30 goes here
Post by: Kerry on September 17, 2005, 12:34:22 AM
Coffee break, so ...

Just testing what NET info I can get ..
 
Title: Re: Question 30 goes here
Post by: Peter Jamtgaard on September 17, 2005, 11:05:51 AM
LE,

I am writing a course for Autodesk University and I would like to share this code with the attendees.

I will give you and the swamp credit. Can you email me your name and response off line to peter@cordecksales.com

I also have a program that I use to upload complete lisp routines into the dictionaries of a drawing. I used a vba macro to unpack them.

With this workaround I think I can bypass the vba and make it so the routine would run automatically without the user having the option to stop the vba macro. This would give the ability to add functionality (lisp functions) to any drawing seamlessly.

I will share the finished code with who ever wants it.

Two thumbs up !!

Peter Jamtgaard P.E.

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....
Title: Re: Question 30 goes here
Post by: Kerry on September 17, 2005, 06:07:24 PM
Like I said, entdel inside out: kill the vlo-vl object then its dictionary. Bye!

This seems to do the job ...

(dictremove (namedobjdict) "WhizGigetalsuperduperDict")
Title: Re: Question 30 goes here
Post by: MP on September 17, 2005, 06:15:00 PM
This seems to do the job ...

(dictremove (namedobjdict) "WhizGigetalsuperduperDict")

Actually that's not enough Kerry, you have to delete the the vlo-vl object then its dictionary.

If you merely delete the WhizGigetalsuperduperDict and then save the drawing, the vlo-vl object still persists (and will still function).
Title: Re: Question 30 goes here
Post by: Kerry on September 17, 2005, 06:28:09 PM
Hi Michael,

Works in my testing.
Run the (dictremove ...
Save ..

ahhh ..
The TST command will continue to be available in the Document untill the drawing is closed ..
but will not persist for the next time the document is Active.

So we may both be correct :)  sort'a
Title: Re: Question 30 goes here
Post by: MP on September 17, 2005, 06:30:11 PM
Hi Michael,

Works in my testing.
Run the (dictremove ...
Save ..

ahhh ..
The TST command will continue to be available in the Document untill the drawing is closed ..
but will not persist for the next time the document is Active.

So we may both be correct :) sort'a

Re-Open that drawing and see what happens.

:)
Title: Re: Question 30 goes here
Post by: Kerry on September 17, 2005, 06:31:02 PM
Command: tst
Unknown command "TST".

and no in-line alert Dialog ..
Title: Re: Question 30 goes here
Post by: MP on September 17, 2005, 06:40:17 PM
Here's what I did yesterday --

(1) I deleted the dictionary entry, left the vlo-vl object alone, saved the dwg and re-opened it. Vlo-vl object would fire. I did this a couple times to confirm.

(2) I started over and deleted the vlo-vl object, then it's parent dictionary, saved and re-opened - quiet as a door mouse.

Today --

Just performed step (1) again for shyts and gyggles; didn't fire. Did it again, didn't fire.

Damn ghosts in the machine ...
Title: Re: Question 30 goes here
Post by: Kerry on September 17, 2005, 06:44:32 PM
hehehehe

dangers when working at the bleeding edge ..

some I know would recomend a mature bourbon.

Just a note for Luis.
Thanks. I've learnt more, and had more fun with this than has been the case for a long time ..
Title: Re: Question 30 goes here
Post by: MP on September 17, 2005, 07:02:11 PM
hehehehe

dangers when working at the bleeding edge ..

some I know would recomend a mature bourbon.

Yep. Still, I feel more comfortable with total eradication. :pissed:

Just a note for Luis.
Thanks. I've learnt more, and had more fun with this than has been the case for a long time ..

I second that, lotsa fun. :laugh:
Title: Re: Question 30 goes here
Post by: GDF on November 28, 2005, 04:21:59 PM
AcDbXrecord

;;;Message Service            (c)2001, John R. Fair III;  $50 Bonus Winner

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;    Message.lsp is a program to store and retrieve       
;;; information about a drawing.  Use it to save notes to   
;;; yourself or others, information about "odd" non-standard
;;; things you were asked to do to a drawing.  Saves right in
;;; the drawing, retrieve the message the next day, next week
;;; or next year.
Title: Re: Question 30 goes here
Post by: GDF on November 29, 2005, 11:01:53 AM
Please disregard my previous post, I was way off.
Title: Re: Question 30 goes here
Post by: LE on November 29, 2005, 11:15:53 AM
Please disregard my previous post, I was way off.

 :-)

Still, that routine is a good one, Gary.
Title: Re: Question 30 goes here
Post by: LUCAS on February 17, 2006, 02:45:29 AM
Selfload is like a virus. Please delete this topic.
Title: Re: Question 30 goes here
Post by: Mark on February 17, 2006, 12:33:18 PM
Selfload is like a virus. Please delete this topic.

Done!
Title: Re: Question 30 goes here
Post by: LUCAS on February 17, 2006, 07:05:11 PM
;;How to stop autoload of vlx?
;;I find nothing.
(vl-load-com)
(if DWGREACTOR
  (vlr-remove DWGREACTOR)
)
(setq DWGREACTOR
       (vlr-dwg-reactor
    (vla-get-database
      (vla-get-activedocument
        (vlax-get-acad-object)
      )
    )
    '((:vlr-begindwgopen . STOP_LOAD))
       )
)
(if DWGREACTOR1
  (vlr-remove DWGREACTOR1)
)
(setq DWGREACTOR1
       (vlr-dwg-reactor
    (vla-get-database
      (vla-get-activedocument
        (vlax-get-acad-object)
      )
    )
    '((:vlr-enddwgopen . STOP_LOAD1))
       )
)
(if DWGREACTOR2
  (vlr-remove DWGREACTOR2)
)
(setq DWGREACTOR2
       (vlr-editor-reactor
    NIL
    '((:vlr-commandwillstart . STOP_LOAD2))
       )
)
(vlr-set-notification DWGREACTOR2 'ALL-DOCUMENTS)
(vlr-set-notification DWGREACTOR1 'ALL-DOCUMENTS)
(vlr-set-notification DWGREACTOR 'ALL-DOCUMENTS)
(defun STOP_LOAD (CALLER CMDSET)
  (setq pp (vl-list-loaded-vlx))
  (print pp)
  (print CALLER)
  (print CMDSET)
)
(defun STOP_LOAD1 (CALLER CMDSET)
  (setq pp (vl-list-loaded-vlx))
  (print pp)
  (print CALLER)
  (print CMDSET)
)
(defun STOP_LOAD2 (CALLER CMDSET)
  (print CALLER)
  (print CMDSET)
)

Title: Re: Question 30 goes here
Post by: Kerry on February 20, 2006, 04:24:00 AM
LUCAS,

What are you trying to do ?

< note WHAT not HOW >


Title: Re: Question 30 goes here
Post by: Kerry on February 20, 2006, 04:28:48 AM
Selfload is like a virus. Please delete this topic.

.. delete this topic. ..
LUCAS, can you clarify this comment. ?

< comment removed .. waiting for clarification >
Title: Re: Question 30 goes here
Post by: LUCAS on February 20, 2006, 08:02:08 PM
See the autoload code of Luis.Can you stop the alert message?
If your answer is no.
You will in danger to open dwg.
If someone make a bad code (like to rename all files name & del some system files)
Title: Re: Question 30 goes here
Post by: Kerry on February 20, 2006, 08:12:20 PM
That < bad code >  is an issue with any program that you are not familiar with .. VB, EXE, ARX, C#, .NET, VLX, FAS, complied LSP, etc ..

Removing this topic will not solve the problem.

Knowledge and testing WILL solve the problem.

... personal opinion.

 
Title: Re: Question 30 goes here
Post by: Chuck Gabriel on February 20, 2006, 08:24:07 PM
I'm inclined to agree with Kerry.  The tool isn't inherently evil, though it could be put to mischievous uses.

Also, how are we supposed to disarm any unruly code that makes use of the mechanism, if we don't study and understand how it works?
Title: Re: Question 30 goes here
Post by: LUCAS on February 20, 2006, 09:28:55 PM
;;OK!ALL USER IN DANGER.
;;CODE FOR AUTOLOAD,BY LUCAS
(vl-load-com)
(vlr-pers (vlr-dwg-reactor
       NIL
       '((:vlr-enddwgopen . BEGIN)) ;ANYNAME
     )
)
(defun C:BEGIN_OPEN ()
  (alert "This is only a test")
  (princ)
)
(alert "This is only a test")
(princ)
Title: Re: Question 30 goes here
Post by: LE on February 20, 2006, 10:01:55 PM
See the autoload code of Luis.Can you stop the alert message?
If your answer is no.
You will in danger to open dwg.
If someone make a bad code (like to rename all files name & del some system files)


Hi Lucas;

I understand your concern, please read the whole thread, in here is also the solution to get rid of this alternative.

 :-)
Title: Re: Question 30 goes here
Post by: LE on February 20, 2006, 10:11:17 PM
And by the way.... this has always been part of the function vlax-ldata-put, what happens is that in the help file, is not well explained... notice the optional argument for [private] data
Title: Re: Question 30 goes here
Post by: LUCAS on February 20, 2006, 10:42:44 PM
And by the way.... this has always been part of the function vlax-ldata-put, what happens is that in the help file, is not well explained... notice the optional argument for [private] data

Autoload not only using vlax-ldata-put

(vlr-pers (vlr-dwg-reactor
       NIL
       '((:vlr-enddwgopen . BEGIN)) ;ANYNAME
     )
)

Title: Re: Question 30 goes here
Post by: LE on February 21, 2006, 09:23:15 AM
Sorry Lucas;

But can not understand what you are trying to say.

What is the code you posted supposed to do? and by the way it is very easy to get rid of that reactor... is that your point?


Thanks.
Title: Re: Question 30 goes here
Post by: Kerry on February 21, 2006, 09:50:45 AM

Is a FAS file.


Thanks Luis ..

.. but can we trust it ?  :lol:  .. you know I'm joking in this case, right !


BUT, generally unless I know <of> the author, I won't download compiled or protected code.
come to think of it, even if I 'know' the author, I still like to know WHAT a routine is actually doing before I use it .. ..
 ... so I s'pose I'm a little paranoid too.


afterthought : 'knowledge is power' so they say
but  Imagination is  more important than knowledge ... Albert  Einstein
Title: Re: Question 30 goes here
Post by: LE on February 21, 2006, 09:56:38 AM

Is a FAS file.


Thanks Luis ..

.. but can we trust it ?  :lol:  .. you know I'm joking in this case, right !


BUT, generally unless I know <of> the author, I won't download compiled or protected code.
come to think of it, even if I 'know' the author, I still like to know WHAT a routine is actually doing before I use it .. ..
 ... so I s'pose I'm a little paranoid too.


I know is hard sometimes to get rid of some useful functions [at least to me].... anyways no big deal and to show that I am not hidding anything at all, hope that would help as in open mode...  :kewl:

Title: Re: Question 30 goes here
Post by: Kerry on February 21, 2006, 10:09:24 AM
Thanks Luis,
Very generous of you, again ..

Regards
kwb
Title: Re: Question 30 goes here
Post by: LUCAS on February 21, 2006, 07:33:58 PM
Sorry Lucas;

But can not understand what you are trying to say.

What is the code you posted supposed to do? and by the way it is very easy to get rid of that reactor... is that your point?


Thanks.

;;the same function of your code
;;CODE FOR AUTOLOAD,BY LUCAS
(vl-load-com)
(vlr-pers (vlr-dwg-reactor
       NIL
       '((:vlr-enddwgopen . BEGIN)) ;ANYNAME
     )
)
(defun C:BEGIN_OPEN ()
  (alert "This is only a test")
  (princ)
)
(alert "This is only a test")
(princ)
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....

Title: Re: Question 30 goes here
Post by: LE on February 21, 2006, 07:55:17 PM
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....

Yep... it does the same.... NOW I understand...  :-)

Now, use this:

Code: [Select]
(dictremove (namedobjdict) "VL-REACTORS")

Save the drawing and tell me if the message is gone ?

I am about to leave the office now... I'll check from home.

Cheers!
Title: Re: Question 30 goes here
Post by: LUCAS on February 21, 2006, 10:28:59 PM
After opened the dwg you can use the code (dictremove (namedobjdict) "VL-REACTORS") to remove the reactor. But how can we stop autoload before open dwg.
I mean how to stop the alert code.
The part of alert code-----can do any thing you like.
Title: Re: Question 30 goes here
Post by: LE on February 21, 2006, 10:41:44 PM
After opened the dwg you can use the code (dictremove (namedobjdict) "VL-REACTORS") to remove the reactor. But how can we stop autoload before open dwg.
I mean how to stop the alert code.
The part of alert code-----can do any thing you like.


Hi Lucas;

I need to rebuild the test I did on my office, over there it was deleted the reactor and the alert message... you mean the ldata-> one no?

I'll be back...
Title: Re: Question 30 goes here
Post by: LE on February 21, 2006, 10:55:25 PM
After opened the dwg you can use the code (dictremove (namedobjdict) "VL-REACTORS") to remove the reactor. But how can we stop autoload before open dwg.
I mean how to stop the alert code.
The part of alert code-----can do any thing you like.


Just by renaming, the VLX or opening the drawing from another folder... then call the part to kill the alert code.
Title: Re: Question 30 goes here
Post by: LUCAS on February 21, 2006, 11:46:24 PM
Opening the drawing from another folder….
=>The autoload code can load the vlx on the search path not just the folder of opening draw. (Test on r2005)

Just by renaming
=>we don’t know which vlx will be load.
Title: Re: Question 30 goes here
Post by: LE on February 22, 2006, 12:14:22 AM
Yes... I see your point...
Title: Re: Question 30 goes here
Post by: Kerry on February 22, 2006, 12:43:13 AM
I know it's only Wednesday afternoon, but it's been a long week ..

Quote
... come up with a solution.

solution To what ?

Exactly what is the problem ?

Title: Re: Question 30 goes here
Post by: LE on February 22, 2006, 09:09:49 AM
Wait... I just went to buy my coffee of the day.... 6:08AM Wendsday

I'll be back...
Title: Re: Question 30 goes here
Post by: LE on February 22, 2006, 09:21:13 AM
Opening the drawing from another folder….
=>The autoload code can load the vlx on the search path not just the folder of opening draw. (Test on r2005)

Remember that the VLX routine will be required to be loaded first and then the drawing needs to be saved first in order to be able the next time, that drawing is opened to autoload the VLX.

So, the harm can be done from any type of file loaded, not just by using this approach... if that is what someone would want to do...

Quote
Just by renaming
=>we don’t know which vlx will be load.

Same, as my comment above.... it can be using any type of file....


Have fun;
Luis.
Title: Re: Question 30 goes here
Post by: LE on February 22, 2006, 09:22:26 AM
Exactly what is the problem ?

None... Kerry  :kewl: