Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/06/2022 in all areas

  1. I think you will have to do external to Autocad in saying that using Shell and some OS function to copy to clipboard then paste image. I have found "powershell" very useful for OS type stuff. It has lots of help examples , I found out how to unzip files from Autocad. Open a web page image then copy. Sorry not much more than that. Not sure if you can map a web Url to a variable ie shorten the path, like you can drives. Any body out there from the Java world. A google https://adamtheautomator.com/powershell-copy-to-clipboard/
    3 points
  2. entmake is the fastest, hence most efficient, way to create any object in AutoCAD. It takes in an association list of dotted pairs to make the entity. Since you said you are new to AutoLISP, you may find some things overwhelming in terms of cons and entmakex, as the codes 10, 40, etc. may mean different things across different entities. Which is probably why the suggestion of others made use of the easiest function to understand, namely "command" (which is the slowest, hence most inefficient, way). To give just a bit on insight for entmake, for a text, 0 - Object Type 10 - Primary point (Text point) 40 - Text Height 1 - Text String 7 - Text Style But for example, in an mline, 40 indicates multiline scale. I never really memorise all the numbers myself and only remember the important ones. As an example running (entget (car (entsel))) and then picking a text returns the association list of dotted pairs listing the details of the entity that you would pass onto the entmake function, like the below: As you can see in mhupp's association list entmake, all the required codes are there, and hence the entity can be successfully created. Every object in AutoCAD will always return a similar list to the entget function. cons basically constructs the dotted pair necessary to create the object. So in mhupp's code for example, (cons 40 (getvar textsize)) first obtains the current text height, and then creates the dotted pair... (40 . 3.5) in the case above. However, knowing how "command" works is also a good thing. The "command" function basically takes in any arguments of inputs, which is all then passed into the command line, much like pasting a text direct into the command line.
    2 points
  3. And this might give you a start using these examples - should be enough after this for you to work it all out? (defun c:testthis ( / MyW MyH acount MySeg MyPt) (setq MyW 5) ; variable MyW - width (setq MyH 10) ; variable MyH - height (setq acount 0) ; a variable (setq MySeg (getint "How Many Segments")) ; set variable from user input 'int' (typical syntacx "get___") (setq MyPt (getpoint "Insertion Point")) ; set variable .. guess what this does (while (< acount MySeg) ; a while loos (command "_.rectang" MyPt (mapcar '+ (list MyW MyH 0) MyPt)) ; CAD command used in the LISP. MapCar '+ adds list 1 to list 2 (command "-hatch" "S" (entlast) "" "") ; CAD commanbdd, HAtch. (entlast) selects the last entity to be created and still in the drawing (setq MyPt (mapcar '+ (list 0 MyH 0) MyPt)) ; LISP variable, MapCAr '+ adds list 1 to list 2 (setq acount (+ acount 1)) ; increase counter ) ; end while loop (princ) ; end silently ) ; end LISP Reckon you can do the fiddling about to insert text and to shade every other block
    2 points
  4. The problem is that your guide curves are not touching the circles. There are large gaps between the ends of the curves and the circles. In order for the program to perform the Loft operation, it needs a precise path to follow from one circle to the other. If there are gaps or overlaps, the operation will fail. I made some adjustments to the curves, to make sure they start and end precisely at the quadrant of each circle and now the Loft command is working, as you can see in the screen grab below. I also attached the dwg file so you can see what I did. guides-adjusted.dwg
    2 points
  5. few things why i don't like (command snaps put "_non" infront of points or depending on zoom level could snap to close objects (pickbox size) even if osmode = 0 (command "_.text" "J" "R" "_non" MyPt "" "" acount "") (command "_.rectang" "_non" MyPt "_non" (mapcar '+ (list MyW MyH 0) MyPt)) ;(command "_.text" "J" "L" MyPt "" "" getstring) this command makes the loop stop fixed ;(command "_.text" "J" "L" "_non" MyPt "" "" (getstring)) ;has to be wrapped to work (...) can add prompt like (getpoint "\nInsertion Point") entmake (entmakex (list '(0 . "TEXT") (cons 10 MyPt) (cons 40 (getvar textsize)) (cons 1 str)))) http://docs.autodesk.com/ACD/2014/ENU/index.html?url=files/GUID-62E5383D-8A14-47B4-BFC4-35824CAE8363.htm,topicNumber=d30e678406
    1 point
  6. Another to print individual items to the command line: (mapcar 'print '(1 2 3 4 5 6 7 8 9 "A" nil)) And for alerting individual lines: (alert (apply 'strcat (mapcar '(lambda (x) (strcat "\n" (vl-princ-to-string x))) '(1 2 3 4 5 6 7 8 9 "A" nil)) ) )
    1 point
  7. Like BigAl, there are many many examples out there, some resources are better than others, and for example this forum is generally very good. LISP is great in that there are usually 3 or 4 ways to make the same thing appear on a drawing, which also makes it trickier as there is often no single correct answer. Looking at BigAls answer above using a command the format in the code is simila to: (command "CommandName" ".....anything else for that commend" ) I usually get the formatting I want by runnig nthrough the command in AutoCAD with a couple of extra tips, so using the above, 'line' In your LISP start with (command ;; to tell the LSIP to use an AutoCAD command (note that the ;; starts a comment, anything afterwards is ignored on that line "line" ;; the command to use, you can also use "_line" and "_.LINE" the prefixes "_" to run the command through the command prompt and "." that the command is written in English (in cse other languages are used, makes it more versatile) Running the command 'line' it is asking for a point "LINE: Select First Point:" pause ;; tells the LISP to wait for user input. Can also use the LISP to put in a point, use a variable name here So next I do what it wants and select a point, it asks "LINE Specify Nect Point or [Undo]", again put in your code what is asked and so on... some commands need you to end them with a "" (as above) You don't -need- a reference for all the commands, just to know how to build up the line in the LISP, hoping that the above will give you a hint - try it. Then you can make entities with entmake, VLA, ....... some are faster than others but unless you are doing it to hundreds of object that speed difference is so small compared to the speed of the user.
    1 point
  8. I think you misunderstood my question, sorry for that. DXF codes are stored in a list of dotted pairs. A dotted list is something else (apparently). A list looks like this: (cons 1 (cons 2 (cons 3 (cons 4 nil)))) which is the same as (list 1 2 3 4) which is the same as '(1 2 3 4) A list of dotted pairs looks like this: (cons (cons 1 2) (cons (cons 3 4) (cons (cons 5 6) (cons (cons 7 8 ) nil)))) which is the same as (list (cons 1 2) (cons 3 4) (cons 5 6) (cons 7 8)) which is the same as '((1 . 2) (3 . 4) (5 . 6) (7 . 8)) This is used for entget data and DXF codes, but it would look something like this: (cons (cons 0 "LWPOLYLINE") (cons (cons 5 "4CCC9") ... )) [terminated with a nil] which is the same as ((0 . "LWPOLYLINE") (5 . "4CCC9") ... ) A dotted list is simply a normal list that isn't terminated with a nil, it looks like this: (cons 1 (cons 2 (cons 3 (cons 4 5)))) which is the same as '(1 2 3 4 . 5) You can verify these examples by pasting the (cons) version into your AutoCAD console, and it will evaluate to the bottom version. Not quite sure what the use case is for a dotted list, but it's fun to know it exists, I guess
    1 point
  9. Easy if you use a dynamic block with multiple Visibility states. Other way google replace block with new block. Multiple answers.
    1 point
  10. Just look into any of the code in the lisp section thousands of examples, any way inside your Autocad is a sample lisp tutorial called "Down the Garden Path" also go to Afralisp has some good beginner lisps. Your 1st item (command "line" (getpoint "\nPick 1st point ") (getpoint "\nPick 2nd point ") "") ; so pick 2 points the "" means end command. There are ebooks etc cheaper than paper version. "like repetitive drawing and writing texts" yes that is where lisp can help, explain what your doing, image or dwg is helpful and we may be able to get you started on your learning journey. Time diff, 4+ hours manual to edit a dwg, its now 2.5 minutes using custom lisp.
    1 point
  11. The 'upgrade' to the forum software a few years ago caused every occurrence of "8)" within code blocks to be removed rendering many thousands of code posts unusable; I've now updated my earlier post to reinstate the missing characters.
    1 point
×
×
  • Create New...