Author Topic: Draw circles from coordinates in selected text file  (Read 3483 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Draw circles from coordinates in selected text file
« Reply #15 on: November 07, 2016, 03:21:48 PM »
Nice tutorial in post #3 mr.Puckett !  :-)
I remember once you posted a code with the following structure:
Code: [Select]
(defun C:test ( / subfun1 subfun2 err )

(defun subfun1 ( n / o ) ; arg expects valid layer name
(setq o (vla-item (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))) n))
)

(defun subfun2 ( s o ) ; arg expects ":vlax-true" or ":vlax-false" string, and layer vla-object
(vla-put-Lock o (read s))
)

(cond
( (not subfun1)
(alert "\nSubfunction #1 not defined.")
)
( (not subfun2)
(alert "\nSubfunction #2 not defined.")
)
( (vl-catch-all-error-p (setq err (vl-catch-all-apply 'subfun1 (list (getstring "\nSpecify layer name: ")))))
(alert (strcat "\nError occured in subfun1: " (vl-catch-all-error-message err)))
)
( (vl-catch-all-error-p (setq err (vl-catch-all-apply 'subfun2 (list (getstring "\nSpecify lock status: ") err))))
(alert (strcat "\nError occured in subfun2: " (vl-catch-all-error-message err)))
)
(T
(alert "\nEverything is being successful.")
)
); cond
(princ)
); defun C:test
So I use the above as a pseudo-template, related to a problem I posted here (theswamp), the "Questions for the experienced programmers" thread.
Where the main issue was how to handle a super-long code without getting lost.
However instead of "divide and conquer strategy" I prefer to name this as "create an assembly" (the same way Autodesk Inventor works) - ofcourse thats individual preference.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Draw circles from coordinates in selected text file
« Reply #16 on: November 07, 2016, 08:40:20 PM »
Thanks for the nod Grrr1337!  :-)

I actually prefer "atomic refactoring" -- reducing a task to the smallest, practical and maintainable divisions of effort.  :lmao:

PS: If you liked post #3 how was post #4? :lol:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Draw circles from coordinates in selected text file
« Reply #17 on: November 08, 2016, 04:01:30 AM »
Thanks for the nod Grrr1337!  :-)

I actually prefer "atomic refactoring" -- reducing a task to the smallest, practical and maintainable divisions of effort.  :lmao:

PS: If you liked post #3 how was post #4? :lol:
Woops I ment reply #3 , sorry.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg