Author Topic: In need of a handout. Please.  (Read 11727 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
In need of a handout. Please.
« Reply #15 on: March 17, 2005, 12:15:50 PM »
Didn't see that second one. I'll give that a try, because you are partly correct. To get the lisp loaded, they gave a toolbar that has to be pressed each time you intend to work with this program. Typing wrap, might work.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
In need of a handout. Please.
« Reply #16 on: March 17, 2005, 12:22:00 PM »
You could do it via event code but I generally avoid event based code unless it's absolutely essential. I don't see this as sporting such necessity.

But I don't pretend to fully appreciate your situation, I'm reading / posting rather quickly here (juggling writing two programs as we speak).

Thanks for your compliment. If I had more time I'd wrapper the wrapper as a generic function you merely pass an argument, like:

Code: [Select]
(defun safecall ( quotedStatement )

    ;; save vars per previous post

    ;; vl-catch-all-apply the quoted statement

    ;; safely restore vars per previous post

    ;; shhhh

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

daron

  • Guest
In need of a handout. Please.
« Reply #17 on: March 17, 2005, 12:35:58 PM »
The code is nice, but the lisp problem remains, because each successive button I have to use ruins my settings the same way. There are a lot of buttons. I do feel a neccesity for event handling. I am aware of the adverse effects.

Here's one I put together for an osmode problem, but the clayer problem needs to know what to set it to, previous to the event.
Code: [Select]
Private Sub AcadDocument_EndLisp()
    Dim sysVarName As String
    Dim sysVarData As Variant
    Dim DataType As Integer
   
    Dim intData As Integer
    sysVarName = "osmode"
    intData = 6175
    sysVarData = intData
    ThisDrawing.SetVariable sysVarName, sysVarData
End Sub

Private Sub AcadDocument_LispCancelled()
    Dim sysVarName As String
    Dim sysVarData As Variant
    Dim DataType As Integer
   
    Dim intData As Integer
    sysVarName = "osmode"
    intData = 6175
    sysVarData = intData
    ThisDrawing.SetVariable sysVarName, sysVarData
End Sub


It's the BeginLisp that I don't quite have a handle on.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
In need of a handout. Please.
« Reply #18 on: March 17, 2005, 12:39:17 PM »
Let me apoligize in advance - no time to post / write more code - but let me say be very careful how you implement this, lest it affect every lisp program.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
In need of a handout. Please.
« Reply #19 on: March 17, 2005, 12:41:15 PM »
Of course. This work isn't for anybody but myself to cure a headache until I can develop a better solution to do my job.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
In need of a handout. Please.
« Reply #20 on: March 17, 2005, 02:56:00 PM »
Daron, use a "BeginLisp" event to grab the current layer and EndLisp event to reset the current layer.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
In need of a handout. Please.
« Reply #21 on: March 17, 2005, 03:00:23 PM »
I got the EndLisp part. It's the BeginLisp that I can't seem to wade through. Will you show me how to get through that puddle?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
In need of a handout. Please.
« Reply #22 on: March 17, 2005, 03:23:09 PM »
Code: [Select]

Option Explicit
Dim CurrLayer As AcadLayer 'global layer variable

Private Sub AcadDocument_BeginLisp(ByVal FirstLine As String)
 If CurrLayer Is Nothing Then 'if there is nothing in the variable now
'this solves the issue of nested lisp functions (not sure if they fire an event)
' but better safe than sorry
  Set CurrLayer = ThisDrawing.ActiveLayer 'save something there
 End If
End Sub

Private Sub AcadDocument_EndLisp()
 If CurrLayer Is Nothing Then ' if there is nothing in the variable
 ' we do nothing (unusual caveat).... it is not easy to test if a value is
' FALSE when comparing to NOTHING .. VBA generates an error ..
 Else
  ThisDrawing.ActiveLayer = CurrLayer 'Set the layer current
  Set CurrLayer = Nothing 'clear the variable
 End If
End Sub

Private Sub AcadDocument_LispCancelled()
 If CurrLayer Is Nothing Then' if there is nothing in the variable
 ' we do nothing (unusual caveat).... it is not easy to test if a value is
' FALSE when comparing to NOTHING .. VBA generates an error ..
 Else
  ThisDrawing.ActiveLayer = CurrLayer 'Set the layer current
  Set CurrLayer = Nothing 'clear the variable
 End If
End Sub


Ok, note that I used a global variable that I can set that will be active across several events. Now, please note that this WILL cause an error if you change the current drawing while in the middle of a lisp program. You could change the global variable to hold the drawing name and layer, then check for the drawing name and layer of the "current" drawing... but that was just a little more coding than I have time for tright now ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
In need of a handout. Please.
« Reply #23 on: March 17, 2005, 04:21:39 PM »
Thank you Keith. I appreciate it.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
In need of a handout. Please.
« Reply #24 on: March 18, 2005, 04:43:19 AM »
Quote from: Daron
<<< Kerry, what you mention about the wrapping it? Isn't that what beginlisp and endlisp /  <<<<.


 Sorry, I've been away most of the day .. I meant wrapped like Michaels post 13 an 14 show.
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.

daron

  • Guest
In need of a handout. Please.
« Reply #25 on: March 18, 2005, 07:47:38 AM »
Thanks everybody. Keith, the beginlisp etc works beautifully. The help file makes it seem more complicated than that.