Recent Posts

Pages: [1] 2 3 ... 10
AutoLISP (Vanilla / Visual) / Re: merge list_layer to another list_layer
« Last post by new_mem on Today at 07:45:14 pm »

why error: ActiveX Server returned the error: unknown name: PurgeAll

Can someone tell me, pls.!

The routine you posted is missing a the function (getfiletxt).


Here is the missing function:
Code: [Select]
Michael Weaver

Given the name of an existing text file as an argument this routine
will return the contents of the file as a list of strings; one line
of file contents per item in the list.

fname the filename to read
dosearch do a library search if non-nil

linelist the list of strings
- nil if the file cannot be opened
- an empty list if the file is empty


(defun getfiletxt ( ;get the contents of a text file
   fname ;file to read
   dosearch ;library search flag
   / ;end of formal argument list
   linelist ;list to return
   inline ;line as read from file
   fileh ;file handle
  ) ;end of local variable list
    ;;open the file
    ((not (if dosearch
    (setq fileh (open (findfile fname) "r"))
    (setq fileh (open fname "r"))
  ) ;_ end of if
     ) ;_ end of not
    ;;read the file and build the return list
    ((not (while (setq inline (read-line fileh))
    (setq linelist (append (list inline) linelist))
  ) ;_ end of while
     ) ;_ end of not
    ;;close the file and return the list
    (T (setq fileh (close fileh)) (reverse linelist))
  ) ;end cond
) ;end getfiletxt
AutoLISP (Vanilla / Visual) / Re: merge list_layer to another list_layer
« Last post by new_mem on Today at 10:04:52 am »
i think can do it

Found some code of Lee Mac and write this code:

(defun c:test ( / lst lst_layer)
    (if (setq lst (LM:getfiles "Select Drawings to Process" nil "dwg;dws;dwt"))

   (setq lst_layer '(("Layer1" "Arch1") ("Layer2"  "Arch2") ("Layer3" "Arch3")))
   (LM:odbx '(lambda ( doc ) (merge_layer doc lst_layer)) lst t)
        (princ "\n*Cancel*")
(defun merge_layer (doc lst / layers lay_obj)
  (foreach name lst
    (make_layer doc (cadr name))
  (setq layers (vla-get-layers doc))
  (vlax-for obj (vla-get-modelspace doc)
    (setq lay_obj (vlax-get obj 'Layer))
    (foreach name lst
      (if (wcmatch lay_obj (car name))
   (vla-put-layer obj (cadr name))
      );foreach name
    );vlax-for obj
  (vla-purgeall doc)
(defun make_layer (doc str / )
  (if (not (wcmatch (vla-item lay (vla-get-layers doc) str)))
    (vla-add (vla-get-layers doc) str)
.NET / Re: Clojure in Cad - a taste of things to come
« Last post by Andrey Bushman on Today at 02:20:16 am »
Thank you for the detailed response.     
.NET / Re: Electron
« Last post by MickD on August 26, 2016, 11:53:31 pm »
Yes, a little and it's pretty good, only tried it for editing some javascript code though, haven't used the 'build desktop app' stuff yet though, looks interesting!

Whoops, I tell a lie!
I have only used Atom which apparently is built on top of Electron and is why I can see the same Icon on my taskbar shortcut (the tooltip also says it's Electron??). It probably explains why I haven't used the desktop stuff either :)

.NET / Electron
« Last post by Jeff H on August 26, 2016, 10:50:55 pm »
Has anyone played with electron?
.NET / Re: Clojure in Cad - a taste of things to come
« Last post by MickD on August 26, 2016, 08:12:29 pm »
Here's a contrived example of how I would go about testing, IOW I wouldn't double up on the functions like this :)
I would also have a 'tests' file to load and run all tests as a test suite as a separate process rather than include them in the source.
If there was an error such as using a string as an input the repl would catch this as well but these tests are logic tests and they work well, particularly for pure type functions.
.NET / Re: Clojure in Cad - a taste of things to come
« Last post by MickD on August 26, 2016, 07:32:02 pm »
Sory, it is not about Clojure, but it can be interesting for C# programmers:

Nice find, will take a look, thanks.

With all of these user controls, you need to do a fair bit of setup work to get the required functionality, especially if you are using a language that is not built into the control.
You need to handle keyboard shortcuts and things like syntax colouring and behaviour.
They do save a lot of work but I wouldn't mind building one from scratch one day just for shiggles. The repl side is hand built using a simple textbox control and has been fun so far and will need some major refactoring once the prototype is working.

It is interesting. Can you use the breakpoints and conditional breakpoints in this code editor?

No, and they are not really required. Clojure does come with some inspection tools but no debugger.

As Clojure is immutable by default a lot of the pain of setting state is removed, this is the main reason we even need a debugger in imperative languages, to check state.
Most functions are pure functions in that they only return an output given certain input and there are no side effects such as setting var's. These pure functions are very easy to test and plug together to form larger functions.

There are ways to have side effects and you need them as you will need to eventually to set/change say an entity's properties with your calculated data, but these can be isolated, tested and viewed with a simple print statement or similar inspection function with output to the repl.

The repl is key here, it allows you test and debug as you code. Enter your function in the repl and test it, if it has a problem you can fix it and retest all in the same session, you have instant feedback.

The current process in C# is:
write code -> build & deploy -> test/debug -> refactor/fix bugs -> repeat until done then final deploy

The process in Clojure will be:
write code -> test/debug -> refactor/fix bugs -> repeat until done then build & deploy

I still have to iron out a few things and finish some basic functionality like loading and saving files and make the repl remember past commands then I will post up a demo with an example of the workflow and how testing can be built in.

The goal of this tool is for 'live' development of code, this code can then be used to build a class library dll just like a C# one. I think I can even do this from the repl and at this point is the only way to have commands registered but while testing, calling from the repl is basically the same.

Bits and Pcs / Re: Happy Birthday ...
« Last post by kdub on August 26, 2016, 04:17:02 pm »
[Lightning bolt]
I never even considered looking on the Intel dvd that came with the delivery ... nor at the NVidea dvd.

duh ...
OK, now I understand. :-D
Programmatically you can add multiple hyperlinks to an object, but only the first is shown to the user. This explains what you are seeing with Ribarm's code.
Code - Auto/Visual Lisp: [Select]
  1. (defun KGA_Data_XdataSet (ename app dataLst)
  2.  (regapp app)
  3.  (entmod
  4.    (append
  5.      (entget ename)
  6.      (list (list -3 (cons app dataLst)))
  7.    )
  8.  )
  9. )
  11. (defun c:test ( / srcElst srcEnm trgEnm)
  12.  (while
  13.    (and
  14.      (setq srcEnm (car (entsel "\nSelect text: ")))
  15.      (wcmatch (cdr (assoc 0 (setq srcElst (entget srcEnm)))) "*TEXT")
  16.      (setq trgEnm (car (entsel "\n  Select entity to attach hyperlink to: ")))
  17.    )
  18.    (KGA_Data_XdataSet trgEnm "PE_URL" (cons 1000 (cdr (assoc 1 srcElst))))
  19.  )
  20.  (princ)
  21. )
Pages: [1] 2 3 ... 10