Recent Posts

Pages: 1 ... 8 9 [10]
91
.NET / Re: Slide labels in Civil 3D
« Last post by Jeff_M on June 27, 2022, 10:22:31 PM »
You can set the ratio of the label on the object. So to have the label at the midpoint of the third segment, the ratio would be 2.5.
92
Also posted here https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automatically-cutting-sections-with-lisp-routine/td-p/11248758

Suggested use TriangV.0.6.7.lsp that has extract long section from a TIN model and its free.
93
I think i have an idea, but i dont have time to present it in code at the moment.

- select 3DPolylines
- select lines that you want to check for intersections with
- make flat copies of 3DPolylines (z = 0)

3DPoly - ((1 . 3DPoly1) (2 . 3DPoly2) (3 . 3DPoly3) etc...)
FlatCopy - ((1 . FlatPoly1) (2 . FlatPoly2) (3 . FlatPoly3) etc...)

- check for intersections between the flat copies and the lines

(setq intersectionPoint3D (vlax-curve-getPointAtParam 3DPoly1... (vlax-curve-getParamAtPoint FlatPoly1... intersectionPoint2D)))

- make a list of all intersection3D points and sort them from the start point of the line
- connect all intersection3D points
94
.NET / Slide labels in Civil 3D
« Last post by sdunn on June 27, 2022, 08:07:27 PM »
Does anyone know if it is possible to slide a label along the feature in .net?  I looked for COM or .net methods and have not been able to find anything.

thank you,
Stacy
95
AutoLISP (Vanilla / Visual) / Re: Can a user have a custom preference saved?
« Last post by danAllen on June 27, 2022, 05:02:22 PM »
I created a routine to load a users lisp file from network folder. The office standard lisps would look for a file called xyz_user.lsp, in a folder named for (getvar "LOGINNAME") under a common staff folder on network (..\\staff\\Dan), and load it if found.
96
AutoLISP (Vanilla / Visual) / Re: Can a user have a custom preference saved?
« Last post by JohnK on June 27, 2022, 03:52:05 PM »
Not a good solution but thinking outside the box a bit; I've always wanted to play with something like the following:

Code - Auto/Visual Lisp: [Select]
  1. (defun hook (func)
  2.   ;; hook
  3.   ;; this function will take an argument and turn it into a
  4.   ;; lambda expression to evaluate. (You can assign to a variable
  5.   ;; and exec it at a later time if you wish.)
  6.   ;;
  7.   ;; By: John (Se7en) K
  8.   ;;    (inspired by something I saw in one of
  9.   ;;     Vladimir Nesterovsky's procedures.)
  10.   ;;
  11.   ;; Ex: (hook '(+ 1 2))
  12.   ;;     > ((LAMBDA nil (+ 1 2)))
  13.   ;;    
  14.   (list (cons 'lambda (cons nil (list func)))) )

I mean "play" as in, something like this:

Code: [Select]
Command: (setq a (hook '(+ 1 2)))
((LAMBDA nil (+ 1 2)))
Command: (eval a)
3
Command: (setq a (hook (cons '- (cdr (car (cddr (car a)))))))
((LAMBDA nil (- 1 2)))
Command: (eval a)
-1

...but you can achieve something very, very similar with no support routines (and probably far better too) --i.e. `hook`-- with defun-q so I've never taking it further then what you see here.
97
AutoLISP (Vanilla / Visual) / Re: Can a user have a custom preference saved?
« Last post by mhupp on June 27, 2022, 11:53:21 AM »
Make a "stat-up" lisp here is mine

Code - Auto/Visual Lisp: [Select]
  1. (setvar 'cmdecho 0)
  2. (setvar 'INSUNITS 1)        ; Sets the Drawing units to inches
  3. (setvar 'THICKNESS 0)       ; Sets THICKNESS TO 0
  4. (setvar 'CECOLOR "BYLAYER") ; Sets color property to "BYLAYER."
  5. (setvar 'CELTYPE "BYLAYER") ; Sets linetype property to "BYLAYER."
  6. (setvar 'CELWEIGHT -1)      ; Sets the lineweight to "BYLAYER."
  7. (setvar 'CELTSCALE 1)       ; Sets the LTScale of new objects to 1.
  8. (setvar 'plinetype 2)       ; convents all 2D polylines to optimized polylines  
  9. (setvar 'auprec 4)              ; angular unit percision 0.0000
  10. (setvar 'luprec 4)              ; linear unit percision 0.0000
  11. (setvar 'selectionmodes 0)  ; Set Selection mode to 0
  12. (setvar 'lunits 2)          ; Set Linear units to Decimal
  13. (setvar 'perspective 0)     ; Turn off Perspective view in current viewport
  14. (setvar 'saveformat 8)          ; Set save to 2010 DXF
  15. (setvar 'nomutt 1)
  16. (vl-cmdf "_.Style" "Standard" "Consolas" "" "" "" "" "")
  17. (setvar 'nomutt 0)
  18. (setvar 'cmdecho 1)

Save it to a trusted file path

Then use appload drag lisp to startup suite the briefcase should run each time you open a file.


use
(servar 'clayer "C-NPLT") instead of (command "-layer" "set" "C-NPLT" "")


98
AutoLISP (Vanilla / Visual) / Can a user have a custom preference saved?
« Last post by MSTG007 on June 27, 2022, 11:25:28 AM »
Maybe the question is to vague, I have some users that want there "startup" to be on a certain layer. (For Example. Layer 0 set to C-NPLT (no plot) Layer).

I know I could write a routine that I could load in each users startup. But there are alot of users.

Would there be a method to have a user activate this command to turn it on. And then if the user would want to turn it off.

Code: [Select]
(command "-layer" "set" "C-NPLT" "")
Once, the command is turned on, it would always be on for each session of AutoCAD until the user decides to turn it off?

Sorry for rambling on.  Thank you for any ideas on this one.
99
AutoLISP (Vanilla / Visual) / Re: How to set function-help as CommonLisp?
« Last post by JohnK on June 27, 2022, 11:16:23 AM »
In other prgraming languages there is typically a "getopt" type of function where you can do something along the lines of:
(if (= argument "--help")... but you often find yourself building a series of checks for the same type but as different configurations. Example:
Code: [Select]
(if (= argument "--help")...
(if (= argument "-help")...
(if (= argument "--H")...
(if (= argument "-H")...
(if (= argument "help")...
(if (= argument "HELP")...
(if (= argument "?")...

this quickly become so cumbersome (for the programmer) you find yourself only dealing with "standard" type of argument syntaxes like "--help, --h, etc." but this is also not very useful (for the end-user). The example I gave above (is very, very crude) is how I would deal with the "help check" to create a sort of "assert" type function check. I choose to use COND because of what it returns and how it evaluates vs the IF statement.

To make things a bit more generic you can build a set of simple check procedures which will deal with more situations.
Code - Auto/Visual Lisp: [Select]
  1. ;; -Support routines.
  2. (set '#test
  3.         (lambda ( result expected )
  4.            (equal result expected)))
  5. (set '#assert
  6.          (lambda ( process expected consequent)
  7.            (cond ((#test (eval process) expected))
  8.                  ((eval consequent)))) )
  9. ;; -Example usage.
  10. ;;  (#assert "a" "1" '((princ "\nWrong argument") (princ)))

Now we can structure our code like this:

Code - Auto/Visual Lisp: [Select]
  1. (if (#assert "a" 1 '((princ "\nI have been given the wrong argument type.") (princ)))
  2.   (princ "\n \"a\" does equal 1 so I can run this portion of code now...")
  3.   )

We can also do more complicated checks like this:

Code - Auto/Visual Lisp: [Select]
  1. ;; -Support function which will always return 1.
  2. (defun myfunction (argument) 1)
  3.  
  4. ;; -Run a check to make sure the return of `myfunction` is equal to 1...
  5. (if (#assert
  6.      '(myfunction "b")
  7.      1
  8.      '((princ "\nI have been given the wrong argument type.") (princ)))
  9.   ;; -if test passes, run the following prompt.
  10.   (princ "\n \"myfunction\" does equal 1 so I can run this portion of code now...")
  11.   )

Not perfect, but this is the basis of an "assertion check".
100
AutoLISP (Vanilla / Visual) / Re: How to set function-help as CommonLisp?
« Last post by d2010 on June 27, 2022, 10:35:05 AM »
AutoLisp is not really set up to work that way because it is an interpreted language and prints
Thank you,
Gracis,,
That is solution. always I check the function the variabiles types.
Code - Auto/Visual Lisp: [Select]
  1. (setq winhelp (list ""))
  2. (Defun dfn_enamk_arc3d(p1 p2  p3 / $rr)
  3.  (command "_ucs" "_w")
  4.   (if (= p1 "--help")
  5.     (progn (setq winhelp (cons "\ndfn_enamk_arc3d create Arc3D:" winhelp))
  6.               (prompt (car winhelp))
  7.               (setq p1 (getpoint "Coordonate #1: "))
  8.     )
  9.   )
  10.  
  11.  (setq p2 (getpoint "Coordonate #2: "))
  12.  (setq p3 (getpoint "Coordonate #3: "))
  13.  (command "_ucs" "_3p" p1 p2 p3)
  14.  (command "_arc" (trans p1 0 1)(trans p2 0 1)(trans p3 0 1))
  15.  (command "_ucs" "_p")
  16.  (setq $rr (entlast))
  17. $rr)
  18.  
  19. (defun dfn_view_pnts(ljfour / $rr a b c d e f x)
  20.  (setq;|a000|;
  21.          b (getvar "VIEWSIZE")
  22.          $rr (getvar "SCREENSIZE")
  23.          c (car $rr)
  24.          d (cadr $rr)
  25.          a (/ (* b c) d)
  26.          x (getvar "VIEWCTR")
  27.          x (trans x 1 2)) (setq;|a67118225|;
  28.          c (list (- (car x) (/ a 2.0)) (- (cadr x) (/ b 2.0)) 0.0)
  29.          d (list (+ (car x) (/ a 2.0)) (+ (cadr x) (/ b 2.0)) 0.0)
  30.          c (trans c 2 1)
  31.          d (trans d 2 1)
  32.   )
  33.   (if (= ljfour "--help"))
  34.      (setq winhelp (cons "\ndfn_view_pnts='calculate Coordinate Ucs of Screen;" winhelp)
  35.             ljfour nil)
  36.   )
  37.   $rr (if ljfour (list c (list (car c) (cadr d) 0.0) (list (cadr c) (car d) 0.0) d) (if (=  ljfour 4) (list c (list (car c) (cadr d) 0.0) (list (cadr c) (car d) 0.0) d) (list c d))))
  38. $rr)
  39. ;Lib:free
  40.  
After-I call two function/s , then I display
(princ winhelp)
Pages: 1 ... 8 9 [10]