Recent Posts

Pages: [1] 2 3 ... 10
AutoLISP (Vanilla / Visual) / Re: Split text string into variables
« Last post by Lee Mac on Today at 07:57:44 am »
Assuming the first item will always be a single character, you could use my String to List function in the following way:

Code - Auto/Visual Lisp: [Select]
  1. (setq str "A0.25,5,4,2,4")
  2. (cons (substr str 1 1) (LM:str->lst (substr str 2) ","))
AutoLISP (Vanilla / Visual) / Split text string into variables
« Last post by Pad on Today at 07:17:38 am »

I would like to split some text strings into variables,  the idea is to click on the text string them click on a block and the corresponding attributes are automatically populated.
In the future I'm going to try and expand this lisp so that it is fully automatic, the text is always in the same position relative to the block insertion point.  But obviously this changes depending on the drawing scale.  But for now I'd like to get a semi-automatic version working.

These two examples are typical:


var1 = A
var2 = 0.25
var3 = 5,4,2,4


var4 = T
var5 = 0.3
var6 = 2.5

Any help with this would be appreciated.
AutoLISP (Vanilla / Visual) / Re: Error Handling
« Last post by Lupo76 on Today at 06:38:01 am »


One of the important things about Ron's code is that the *error* function is declared local to the main routine, and does not use the setting and getting of old-error

I noticed that you ignored that.

Ok this is true.
But Ron's code simply deletes the lines stored in the "tmp" list.

A lisp function can be very complex and do many things (drawing objects, turn off and on layers, change dimension styles or text, etc. Etc.).
It can happen, in some conditions not provided, that the function goes wrong prematurely, or the user presses ESC to cancel it.

With my initial code when this occurs all is canceled.
With Ron's code I have to be attentive to every possible variation to the design caused by the function during its production and cancel it when crash: this involves too much work.

I'm looking for a code that I can use anywhere, any lisp function or in most of them, so that I can concentrate only on the solution of errors for user input (initget, etc.).
Visual DCL Programming / Re: Using "ENTER" key in "edit-box"
« Last post by roy_043 on Today at 06:23:25 am »
If the edit_box has the allow_accept attribute set to 'true' hitting enter should trigger the default button in the dialog.
Visual DCL Programming / Using "ENTER" key in "edit-box"
« Last post by ymg on Today at 05:40:41 am »
Maybe there is  a better way to do it, but here goes.

Code - Auto/Visual Lisp: [Select]
  1. ;;                                                                            ;
  2. ;; Action_Focus    by ymg                                                     ;
  3. ;;                                                                            ;
  4. ;; Given a list of "Tile Key" will create necessaries "action-tile"           ;
  5. ;; be able to use "ENTER" key in "edit-box" of a dialogue.                    ;
  6. ;;                                                                            ;
  7. ;; The Dialogue file must not contain any "is_default = true;"                ;
  8. ;;                                                                            ;
  10. (defun Action_Focus (l)
  11.   (setq l (append l '("accept")))
  12.   (mode_tile (car l) 3)
  13.   (mapcar '(lambda (a b)
  14.      (action_tile a (strcat  "(if (= $reason 1)"
  15.      "   (mode_tile \"" b "\" " (itoa 2) ")"
  16.                                      "   (setq  a  $val)"
  17.      ")" ))) l (cdr l)
  18.   )
  19. )                          

I find it somewhat perplexing that we cannot use the "ENTER" key to enter
simple data in "edit-box"

The only solution I could find was a suggestion by MSasu at CadTutor to use
something like the following:
Code: [Select]
(mode_tile "EditBox1st" 2)                                  ;set initial focus to first edit box
 (action_tile "EditBox1st" "(mode_tile \"EditBox2nd\" 2)")   ;switch focus from first to second
 (action_tile "EditBox2nd" "(mode_tile \"EditBox3rd\" 2)")   ;switch focus from second to third
 (action_tile "EditBox3rd" "(mode_tile \"accept\" 2)")       ;set final focus from third to OK

Problem with this method is that you must go through all the boxes in order to
even be able to cancel or accept the dialogue, as the "action-tile" gets fired before
"cancel" or "accept" and focus is tranfered to the next tile.

The proposed "action-focus" routine get rid of this problem, by testing the value
of  $reason.  If value is equal to "1", we either pressed "ENTER" or Selected another
tile. All we do at this point is to accept anything that was entered and do not change

Seems to work OK, but maybe somebody knows a better way.


.NET / Re: GeoLocationData ScaleFactor returns wrong value
« Last post by Sheldon1874 on October 08, 2015, 08:25:06 pm »
So I know nothing about the flavor of autoCAD you are using.  What I do know about is geomatics.  First thoughts are:  are you using enough precession.  Scale factors for a particular projection are often very close to 1, 0.997 is the starting point for my local circumstance.  Second: you can't scale and rotate using a point, you need vectors.  Like I said not sure how   "Matrix3d.Rotation" and "Matrix3d.Scaling" work but they must need vectors not points?
.NET / Re: Same Code, Multiple Projects, Multiple Builds
« Last post by CADbloke on October 08, 2015, 07:05:22 pm »

Your criteria/explanations are still a bit jumbled up and I'm still having a hard time envisioning this but I'm getting a better idea of your plan (I think). -i.e. sometimes you are describing a library, and sometimes you're describing a file sync thing, and other times you're describing a processor of sorts.
Yeah, the state of my head this week is not good.

Code Cloner...wait, I think it needs a better, more applicable name like "Code Linker"
I don't think I have explicitly said this but ... This will only work in Visual Studio. It is not a build process, it is a way to share the same code between projects.

All Code Cloner does is adds links to existing code files into a target csproj. No file is copied, no source code is parsed. The original csproj file is mined for its source code <Include=...> things and that information is used to add links to the target csproj file. That's all. It ends there. The  target csproj is all it touches. It automates the add existing file as a link process. That link explains it really well, and also some of the reasons you would do this.
I want to work with the original files, not proliferate copies all over the place that need to be kept track of and in sync with the original. If I have a bright idea and add it to a target project (because I'm tired and forgot to switch to the original source project) then I want the changes to propagate to all projects - linked files solves that. One version of the Truth.

Libraries are great. This has nothing to do with libraries, it is all about re-using existing code in a new Visual Studio Project - building the same thing a different way.

Try it, it already works. I just pushed a fix to Github that fixes the issue of refreshing the target project when nothing changed - it leaves it alone now. Changing code inside linked files does not affect the target project, a link only changes if you add / delete / move a file.

You make a call to CodeCloner.exe whenever you want to refresh the target projects. You can check the projects against each other in a text-diff to see what is missing, as a confidence test. As an example, diff the 2x csproj files in the Github project after you build them a couple of times, you will see the added lines in the XML and how they compare to the original.

Here is an illustrated process. I cloned the Github source and opened it in Visual Studio

Note the post-build process (Project - Properties). In this particular instance I put it there because it actually needed to be built for the demo to work. It's also not the standard command line call because I used a macro variable to call the actual EXE. You would normally call CodeCloner ..\..\..\_Builds\CodeCloner-3.5\CodeCloner-3.5.csproj. Putting it in a pre or post build process means it happens automatically, you don't have to think about it.

Note the emptiness of the .NET 3.5 project. Now, right-click the CodeCloner Project in Solution Explorer and click "Build"

Visual Studio will (or not, this may depend on your settings) see the 3.5 project has been tampered with and ask to reload it

Reload it.

Job done. Note the new linked files in the 3.5 project

You can now build the 3.5 project and it will build a .NET 3.5 version of CodeCloner (the original is .NET 4.5.2). You're finished. No, really. Done. That's it.

There are no new files in the 3.5 project. Open the directory on disk and have a look. Have a look at the changes for the next Git commit in the Solution, the only changes are the linked files in _Builds\CodeCloner-3.5\CodeCloner-3.5.csproj

That's all it does. All you need to use it is the EXE. All this Github repo does is builds the exe. I used it as an example of itself which is probably the cause of the confusion here.
AutoLISP (Vanilla / Visual) / Re: Error Handling
« Last post by Kerry on October 08, 2015, 02:08:54 pm »


One of the important things about Ron's code is that the *error* function is declared local to the main routine, and does not use the setting and getting of old-error

I noticed that you ignored that.

AutoLISP (Vanilla / Visual) / Re: Error Handling
« Last post by Lupo76 on October 08, 2015, 01:30:14 pm »
I'm a little confused on the (= 1 1) 1 will always = 1.

Why not use (while t (command "_.line" "0,0,0" "10,10,0" "")) if your intent is an endless loop exitable only with escape.

You are right!
but the problem remains :-(
AutoLISP (Vanilla / Visual) / Re: Error Handling
« Last post by ChrisCarlson on October 08, 2015, 01:08:39 pm »
I'm a little confused on the (= 1 1) 1 will always = 1.

Why not use (while t (command "_.line" "0,0,0" "10,10,0" "")) if your intent is an endless loop exitable only with escape.
Pages: [1] 2 3 ... 10