Author Topic: reloading acad.lsp when..  (Read 3502 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
reloading acad.lsp when..
« on: September 25, 2005, 10:23:52 PM »
Hi,

I'm trying to find a way to reload acad.lsp when user change profile...

any idea ?



Keep smile...

deegeecees

  • Guest
Re: reloading acad.lsp when..
« Reply #1 on: September 26, 2005, 11:54:12 AM »
You could use Lisp or VBA to load the profile, then call acad.lsp within the Lisp or VBA.

Just a suggestion.

Bob Wahr

  • Guest
Re: reloading acad.lsp when..
« Reply #2 on: September 26, 2005, 12:03:29 PM »
Or you could reload the acad,lsp with VBA using an event when the profile is changed.

deegeecees

  • Guest
Re: reloading acad.lsp when..
« Reply #3 on: September 26, 2005, 12:05:27 PM »
Yes Bob, I was looking into what command/event to trigger that. My brain aint workin too good this morning, got a suggestion?

Murphy

  • Guest
Re: reloading acad.lsp when..
« Reply #4 on: September 26, 2005, 12:21:45 PM »
Something like this?
Code: [Select]
Public WithEvents objAp As AcadApplication

Private Sub AcadDocument_Activate()
Set objAp = GetObject(, "AutoCAD.Application.15")
End Sub

Private Sub objAp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)
If SysvarName = "CPROFILE" Then
    'Do your thing
End If
End Sub

Bob Wahr

  • Guest
Re: reloading acad.lsp when..
« Reply #5 on: September 26, 2005, 12:32:23 PM »
This isn't tested or well thought out but it should do it.  Another thought would be to use a reactor and load it whenever cprofile changed.
Code: [Select]
Public strProf As String

Private Sub AcadDocument_BeginSave(ByVal FileName As String)
If CommandName = "OPTIONS" Then
  strProf = ThisDrawing.GetVariable("CPROFILE")
End Sub

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If CommandName = "OPTIONS" Then
  If Not ThisDrawing.GetVariable("CPROFILE") = strProf Then
    thisdrawing.SendCommand "(load"acad.lsp")"
  End If
End If
End Sub
Yeah, like that Murph.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: reloading acad.lsp when..
« Reply #6 on: September 26, 2005, 01:17:14 PM »
ok....thanks for all your suggestion..

but..

sincerely I don't like using VBA with AutoCAD....
maybe other software....but not AutoCAD and load all VBA module just for a simple routine. :|

sorry,......this is my opinion. :kewl:

I would have espere that it is there a variable or something like that..
but ok...I'll make my own routine..

thanks a again. ^-^
Keep smile...

Bob Wahr

  • Guest
Re: reloading acad.lsp when..
« Reply #7 on: September 26, 2005, 01:27:48 PM »
you could do the same thing with a vlisp reactor.  if CPROFILE changes, the profile changed.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: reloading acad.lsp when..
« Reply #8 on: September 26, 2005, 07:32:45 PM »
that exacly what I did... 8-)
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: reloading acad.lsp when..
« Reply #9 on: September 27, 2005, 03:56:23 AM »
Andrea,
I'd be interested in seeing the code you are using.

I wonder what the effect on performance would be using  the callbacks to :VLR-sysVarChanged ?? { or the VBA equivalent from an Event trap }
 .. the firing rate on this reactor would be fairly high I think.

Have you considered using a partial menu load with unique names for each profile and having your load instructions in the associated .MNL file. ?
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: reloading acad.lsp when..
« Reply #10 on: September 27, 2005, 04:29:17 AM »
This is an example of the firing Rate

The Commands issued were
DimLinear
Mtext
and 2 button clicks to change to Layout1 and back to modelspace.

... oh, I have a reactor on the DIM commands to ensure the Dimension Layer is set correctly when I place dimensions ...
.. .. so 2 firings were due to my own reactors changing the Layer, then restoring it .. { see the  System variable: CLAYER reports }
27 callbacks for the above 4 actions.

There was no lisp routines run with multiple calls to "SETVAR" .. I'll leave that to you to check

This is the Reactor Initialiser and callback
Code: [Select]
(if rkb:sysvarchanged
 (vlr-remove rkb:sysvarchanged)
)

(setq rkb:sysvarchanged
      (vlr-sysvar-reactor
       nil
       '((:vlr-sysvarchanged . rkbf:reportvarchange))
      )
      rkbg:FiringCount 0
)

(defun rkbf:reportvarchange (r d)
 (setq rkbg:FiringCount (1+ rkbg:FiringCount))
 (princ (strcat "\nSystem variable: "
                (car d)
                " changed. :Count = "
                (itoa rkbg:FiringCount)
                "\n"
        )
 )
)
This is the Command report :
Quote
Command: _dimlinear
System variable: CLAYER changed. :Count = 1

Specify first extension line origin or <select object>:
System variable: LASTPOINT changed. :Count = 2

Specify second extension line origin:
System variable: LASTPOINT changed. :Count = 3

Non-associative dimension created.
Specify dimension line location or
[Mtext/Text/Angle/Horizontal/Vertical/Rotated]:
Dimension text = 104.66
System variable: CLAYER changed. :Count = 4

Command:
Command:
Command: _mtext Current text style:  "Standard"  Text height:  2.5
Specify first corner:

System variable: LASTPOINT changed. :Count = 5
Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width]:

System variable: LUNITS changed. :Count = 6

System variable: LUNITS changed. :Count = 7

System variable: LUNITS changed. :Count = 8

System variable: LUNITS changed. :Count = 9

System variable: LUNITS changed. :Count = 10

System variable: LUNITS changed. :Count = 11

System variable: TEXTSIZE changed. :Count = 12

System variable: TEXTSTYLE changed. :Count = 13

System variable: TSPACETYPE changed. :Count = 14

System variable: TSPACEFAC changed. :Count = 15

Command: *Cancel*

Command: *Cancel*

Command:  <Switching to: Layout1>

System variable: TILEMODE changed. :Count = 16

System variable: REGENMODE changed. :Count = 17

System variable: REGENMODE changed. :Count = 18
Regenerating layout.

System variable: PLIMMIN changed. :Count = 19

System variable: PLIMMAX changed. :Count = 20

System variable: PLIMMIN changed. :Count = 21

System variable: PLIMMAX changed. :Count = 22

System variable: PLIMMIN changed. :Count = 23

System variable: PLIMMAX changed. :Count = 24
Regenerating layout.
Regenerating model - caching viewports.

Command: *Cancel*

Command: *Cancel*

Command:  <Switching to: Model>

System variable: CLAYER changed. :Count = 25

System variable: TILEMODE changed. :Count = 26
Restoring cached viewports.

System variable: UCSNAME changed. :Count = 27
« Last Edit: September 27, 2005, 04:39:01 AM by Kerry Brown »
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.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: reloading acad.lsp when..
« Reply #11 on: September 27, 2005, 05:33:45 PM »
Have you considered using a partial menu load with unique names for each profile and having your load instructions in the associated .MNL file. ?


hug ?  :?
Keep smile...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: reloading acad.lsp when..
« Reply #12 on: September 27, 2005, 05:41:25 PM »
hug ? :?

I know it's a french thing but this place is getting a little friendly for me.

You two get a room please.
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: reloading acad.lsp when..
« Reply #13 on: September 27, 2005, 05:44:55 PM »
 :lmao:
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: reloading acad.lsp when..
« Reply #14 on: September 27, 2005, 05:53:56 PM »
Have you considered using a partial menu load with unique names for each profile and having your load instructions in the associated .MNL file. ?


hug ? :?

Consider this :
Have folders named the same as your profiles.
In each folder have a <partial> menu names say RELOAD.MNU
and a support file named RELOAD.MNL

Each profile could be pathed to it's own relevant folder so that the correct partial .MNU and .MNL are loaded for each profile.
.. that way you wont need the reactor and be hit with an extra 1000 odd callbacks each hour.
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.