Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/29/2025 in all areas

  1. Ahh this is perfect, and most perfectly You sir are a Legend
    1 point
  2. Here is a quick and dirty example, using a data entry helper function. Some other ways to do the same thing also shown (remmed out) in code. (defun C:LineMPL (/ MP P1 P2 OldOsnap) ; Draw line based on centre point and length ; KJM - Jan 2025 ; Uses custom functions: ; getdata ; Get inputs ; Midpoint (setq MP (getpoint "\nSelect line midpoint...")) ; Length with pre-set default (if (and (not MyLength) (not (type MyLength) 'REAL)) (setq MyLength 10.0)) ; hard coded starting default (setq MyLength (getdata "R" "Enter length " MyLength)) ; Angle (even though you do not need, someone else might. Rem it out if not needed) (if (and (not MyAngle) (not (type MyAngle) 'REAL)) (setq MyAngle 0.0)) ; hard coded starting default (setq MyAngle (getdata "R" "Enter angle (degrees) " MyAngle)) ; Better method that allows pick, but no default ;(setq MyAngle (getangle MP "\nSelect or enter angle...")) ; Make line endpoints (setq P1 (polar MP (+ MyAngle pi) (* 0.5 MyLength))) (setq P2 (polar P1 MyAngle MyLength)) ; Draw line (or could entmake the line - see example below) ; Cancel any current object snaps (setq OldOsnap (getvar "OSMODE")) (setvar "OSMODE" 0) (command ".LINE" P1 P2 "") ; Reset object snap setting (setvar "OSMODE" OldOsnap) ; Draw line using entmake (do not need to worry about object snaps) ;(entmake (list '(0 . "LINE") (cons 10 P1) (cons 11 P2))) (princ) ) ; ========================================================= Helper functions (defun GetData (DataType DataPrompt Default / Data) ; Get Integer, Real, String or Point, returns Data ; KJM 1990? ; Input: ; DataType - (string, typ 1 char) desired type of value ; where "I" = integer ; "R" = Real ; "S" = String ; "P" = Point (or vector) ; DataPrompt - (string) text prompt ; Default - (integer or real) default value ; Returns ; value of type specified by 'DataType' ; Uses custom functions: ; none! (setq DataType (strcase (substr DataType 1 1))) (prompt (strcat "\n" DataPrompt " <")) (princ Default)(princ) (cond ((= DataType "I") ; Integer (progn (setq Data (getint ">: ")) (if (= Data nil) (setq Data Default)) ) ) ((= DataType "R") ; Real (progn (setq Data (getreal ">: ")) (if (= Data nil) (setq Data Default)) ) ) ((= DataType "S") ; String (with spaces) (progn (setq Data (getstring 1 ">: ")) (if (= Data "") (setq Data Default)) ) ) ((= DataType "P") ; Point (progn (setq Data (getpoint ">: ")) (if (= Data nil) (setq Data Default)) ) ) ) Data ; return data )
    1 point
  3. @Sharper Here is a fairly simple one that gives you the option to enter a length, or select an endpoint of the line to make the distance. (defun c:MIDLINE (/ an ln mp p2) (if (and (setq mp (getpoint "\nSelect a point for the Middle of the Line: ")) (or (setq ln (getdist "\nEnter the length of the line or <Enter to select Endpoint>: ")) (setq p2 (getpoint mp "\nSelect an Endpoint for the line: ") ln (if p2 (* (distance mp p2) 2)) ) ) ) (progn (setq an (if p2 (angle p2 mp) 0.0)) (command "._Line" "_non" (polar mp an (/ ln 2)) "_non" (polar mp (+ an pi) (/ ln 2)) "") ) ) (princ) ) NOTE: if you use the "Select Endpoint" option. this will draw the midline at any angle created with the midpoint and endpoint.
    1 point
  4. Maybe you didn't call the function correctly. The correct way to call the function could be: (descargaWEBarch "https://www.webco.net/..." "c:\\image.jpg") because the image to download from that URL is .jpg, of course But remember that you must have write permissions on the destination directory. As I said, the ideal way to avoid this is to select the 'Documents' folder DescargaWEBarch.mp4
    1 point
  5. Hi EIA. I'm sure there's someone who can explain it better than me. But I'll try: The code '0' is associated with the object type. Therefore, if '(cdr (assoc 0 en))' returns 'ATTRIB', it means that the object being analyzed is an attribute. In the database, blocks are always stored in this way: first the main container entity, then the entities that compose it up to an object type 'ENDBLK' that serves to end the main entity. Since objects in AutoCAD are stored in order, to access the objects that compose a block, after obtaining the entity name of the main container entity, you must use 'ENTNEXT' successively until the returned object is an 'ENDBLK' object.
    1 point
  6. The final check can be done with the 'guardar' function. This function is only executed if the file has been downloaded successfully. I have slightly modified the code to display a message in this case. However, Saxlle's option may be interesting. (defun descargaWEBarch (URL archLocal / arch flujo objHTTP guardar) (defun guardar (idArchivo archDestino / arch flujo) (if (setq arch (vlax-create-object "ADODB.Stream")) (progn (setq flujo (vl-catch-all-apply (function (lambda () (vlax-put arch "Type" 1) (vlax-invoke arch "Open") (vlax-invoke-method arch "Write" idArchivo ) (vlax-invoke arch "SaveToFile" archDestino 2 ) ) ) ) ) (vlax-release-object arch) (if (not (vl-catch-all-error-p flujo)) archDestino (alert "Error: The file was downloaded but not could be written") ) ) ) ) (if (vl-filename-directory archLocal) (if (setq objWHTTP (vlax-create-object "WinHTTP.WinHTTPRequest.5.1")) (progn (setq flujo (vl-catch-all-apply (function (lambda () (vlax-invoke-method objWHTTP "Open" "GET" URL :vlax-false) (vlax-invoke objWHTTP "Send") (if (= (vlax-get-property objWHTTP "Status") 200) (vlax-get-property objWHTTP "ResponseBody" ) ) ) ) ) ) (vlax-release-object objWHTTP) (if (and flujo (not (vl-catch-all-error-p flujo))) (guardar flujo archLocal) ) ) ) (progn (princ "\n*** ERROR: El directorio especificado no existe ***") nil ) ) )
    1 point
  7. That's great I was looking for a way to relate segments based on collinearity (equations of the line) and the distance between the ends. But your solution is much easier and more practical. Also, you have revealed to me a quality of the 'boundary' command that I didn't know about.
    1 point
  8. I've now updated this program and added it to my site here.
    1 point
  9. Very nice @marko_ribar. @maahee there is rules about stairs re rise and run. A better approach is to pick start point ground floor and end point 1st floor then work out the rise and runs.
    1 point
  10. You have my 3dstairs posted here... https://www.cadtutor.net/forum/topic/31704-stairs-software/page/2/#comment-455078 Look at the *.zip file attached within post... HTH. M.R.
    1 point
  11. If you don't understand the code ask, most people will add explanations line by line. Explaining what is going on. Big list of VLA functions attached then just google what your maybe trying to understand. Sorry no author name in the Autolisp functions. The_Visual_LISP_Developers_Bible.pdf Books such as by Reonaldo Togeros, can get on Kindle as Ebook nice thing is can copy and paste code. List of all vl commands.txt AUTOLISP FUNCTIONS CATOGRIZATION.pdf
    1 point
×
×
  • Create New...