Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/07/2020 in all areas

  1. since both functions vars localized then you will get nil unless during debugging/testing you have few global symbols (variable) exposed, then it returns that global value. assume you have variables named a b c d e exposed to global, reset it (foreach x '( a b c d e ) (set x nil) )
    1 point
  2. another for VLX vlax-add-cmd vl-acad-defun or undefun (vl-acad-defun (defun c:tt ()(princ "Hello World" )(princ) )) 2172 'c:tt not sure why it always return as integer? 2172 FWIW Tools->General Options->Diagnostic->Report statistics during syntax checking (must be checked) another interesting in VLIDE, when you change the settings in Tools->Environment Options->Visual LISP Format Options after formatting, the bottom comments will be updated real time. ie: you can also change the options in the comment list then reformat (triangle button) ;|«Visual LISP© Format Options» (120 2 1 1 nil "end of " 50 9 0 0 0 T nil T T) ;*** DO NOT add text below the comment! ***|; 120 Right text margin 2 Narrow style indentation 1 Single-semicolon comment indentation 1 Closing paren style (0/1/2) nil Insert form closing comment (T/nil) "end of " Form closing comment prefix 50 Approximate line length 9 Maximum wide-style car length 0 Setting case for symbol protected (0/1/2) 0 Setting case for symbol unprotected (0/1/2) 0 Long list format style (nil/2/0/1) T Insert tabs (T/nil) nil Preserve existing line breaks (T/nil) T Split comments (T/nil) T Save options in source file (T/check in dialog box for nil)? not sure
    1 point
  3. not sure if OP wants to apply dimension? refer to RHS in the picture, 1 ,2 ,3, B= text position Command: DIMANGULAR Select arc, circle, line, or <specify vertex>: <ENTER> Specify angle vertex: <--- pick p1 (center) Specify first angle endpoint: <--- pick p2 Specify second angle endpoint: <--- pick p3 then place B Non-associative dimension created. or vb method object.AddDim3PointAngular(AngleVertex, FirstEndPoint, SecondEndPoint, TextPoint) (apply 'vla-AddDim3PointAngular (cons *modelspace* (mapcar ''((p) (vlax-3d-point (trans p 1 0))) (list p1 p2 p3 B) ) ) )
    1 point
  4. Assuming that you are looking to return the smallest section of the string which matches the supplied pattern, you could use a function such as the following: (defun LM:wcmatchx ( str pat ) (if (wcmatch str pat) (cond ( (LM:wcmatchx (substr str 2) pat)) ( (LM:wcmatchx (substr str 1 (1- (strlen str))) pat)) ( str ) ) ) ) For example: _$ (LM:wcmatchx "abc123def" "*###*") "123" But this relatively simplistic approach isn't bulletproof and may not be applicable to all conceivable wcmatch pattern & string combinations. A more robust approach might be to turn to Regular Expressions and use the Execute method.
    1 point
  5. I strongly disagree with this practice: failing to declare the scope of variables before running a program has the potential to introduce unexpected & undesirable behaviour into an otherwise working program, resulting in self-inflicted debugging. If the objective is to inspect variables following evaluation, I would suggest either printing the value of the variable using print or prin1 or watching the variable in the Visual LISP IDE.
    1 point
  6. (setq A (- (angle p1 p3) (angle p1 p2))) (setq B (+ (* 2.0 PI) (angle p1 p4) (- (angle p1 p2)))) I can not test it right now, but it should work...
    1 point
  7. Yes, that's for sure... Localizing your variables is a very good practice, as devitg says, no doubt. And it's not only variables you can localize, functions are also the same. (defun function1 ( / ) (defun tstfunc (a b) (/ (+ a b) 2) ) (tstfunc 4 10) ) ;; ----------------------------------------------------- ;; (defun function2 ( / ) (defun tstfunc (a b) (/ (- a b) 2) ) (tstfunc 4 10) ) ;; ----------------------------------------------------- ;; (defun function3 ( / ) (tstfunc 5 7) ) Take above for example. Try calling function1 then function3. Now try calling function2 then function3. You'll see that even though you run function3 twice, the result is different when you run it the first time and the second. As such, this is why localizing variables are important. Then there's another case where users do (setq a (cons b a)) without ever setting (setq a nil) at the beginning. If you don't localise the variable a, the result you'll get will be screwed.
    1 point
×
×
  • Create New...