Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/11/2020 in all areas

  1. dlanorh missed one closing bracket: should be: (SETQ C (RTOS (/ a 10000)))
    2 points
  2. If you really must use JOIN, try the following approach: (command "_.selectsimilar" selset1 "") (initcommandversion) (command "_.join" (cadr (ssgetfirst)) "")
    2 points
  3. Per Jonathan's response, this could be achieved using entmake, though a basic command call should still operate successfully providing the syntax is correct. Here are three possible methods: 1. CIRCLE Command Call (defun c:test1 ( / cen ) (while (setq cen (getpoint "\nSpecify circle center <exit>: ")) (command "_.circle" "_non" cen 0.5) ) (princ) ) 2. Vanilla AutoLISP using entmake (defun c:test2 ( / cen ocs ) (setq ocs (trans '(0.0 0.0 1.0) 1 0 t)) (while (setq cen (getpoint "\nSpecify circle center <exit>: ")) (entmake (list '(000 . "CIRCLE") (cons 010 (trans cen 1 ocs)) '(040 . 0.5) (cons 210 ocs) ) ) ) (princ) ) 3. ActiveX using the addcircle method (defun c:test3 ( / cen spc ) (setq spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object)) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace) ) ) (while (setq cen (getpoint "\nSpecify circle center <exit>: ")) (vla-addcircle spc (vlax-3D-point (trans cen 1 0)) 0.5) ) (princ) ) Each example will operate successfully under all UCS & View settings, though the Vanilla AutoLISP example is likely to be the fastest.
    1 point
  4. It draws the circle just fine for me with radius 0.5. I always try to avoid (command …) [just a habit of mine to increase evaluation speed] so I would do: (repeat ntimes (entmake (list '(0 . "CIRCLE") (cons 10 (getpoint "\nSpecify center: ")) '(40 . 0.5) ) ) ) Or keep clicking until you press enter: (while (setq pt (getpoint "\nSpecify center <Exit>: ")) (entmake (list '(0 . "CIRCLE") (cons 10 pt) '(40 . 0.5) ) ) )
    1 point
  5. Not as fancy as bigal by using dcl, but here's my go: (defun c:textlast ( / ent i ins newtxt pos ss txt) (if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT")))) (progn (setq newtxt (getstring T "\nSpecify text to append: ") ins (progn (initget 5) (getint "\nSpecify position from end: ")) ) (repeat (setq i (sslength ss)) (setq txt (cdr (assoc 1 (entget (setq ent (ssname ss (setq i (1- i))))))) pos ((lambda (x) (if (< x 0) 0 x)) (- (strlen txt) ins)) ) (entmod (subst (cons 1 (strcat (substr txt 1 pos) newtxt (substr txt (1+ pos)))) (assoc 1 (entget ent)) (entget ent) ) ) ) ) ) )
    1 point
  6. Recently I started topic JOIN-BUG at theswamp... I strongly suggest you that you study complete topic... http://www.theswamp.org/index.php?topic=55918.0 Regards, M.R.
    1 point
  7. Firstly, it is worth noting that there is a difference in the structure of the transformation matrices returned by the nentsel & nentselp functions: where the nentselp function returns a standard 4x4 transformation matrix, as might be used by the ActiveX transformby method and vlax-tmatrix function, the nentsel function returns a 4x3 matrix which, if appended with a column vector (0 0 0 1) to form a 4x4 matrix, represents the transposition of the matrix returned by nentselp. As such, I always opt to use the nentselp function so that the transformation matrix is consistent with those used elsewhere in the LISP and ObjectARX APIs. The easiest way to transform your blocks would be to use the ActiveX transformby method, supplied with a transformation matrix generated from the 4x4 matrix returned by the nentselp function; though, note that such a transformation is limited to orthogonal matrices, and therefore cannot handle non-uniformly-scaled blocks. Here is a quick example using this method: (defun c:test1 ( / blk sel ) (setq blk "Block1") (cond ( (not (tblsearch "block" blk)) (princ (strcat "\n" blk " not found in the active drawing.")) ) ( (not (setq sel (nentselp "\nSelect nested block: ")))) ( (/= 4 (length sel)) (princ "\nSelected object is not nested.") ) ( (vla-transformby (vla-insertblock (vlax-get-property (vla-get-activedocument (vlax-get-acad-object) ) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) (vlax-3D-point 0 0) blk 1.0 1.0 1.0 0.0 ) (vlax-tmatrix (caddr sel)) ) ) ) (princ) )
    1 point
  8. Have a look at Lee's Polyline Join program.
    1 point
  9. The nentsel & nentselp functions facilitate subentity selection, with the last element of the selection list also providing information about the parent entities in which the selected entity resides.
    1 point
  10. artos function? click here (artos 1.234 ) ;--> 1.2 m² (artos -1234.56 ) ;--> -0.123 ha (artos 12345.678 ) ;--> 1.23 ha (artos (getvar 'area)) ;--> 0.00 m² example in your code change to:
    1 point
  11. 1 hectare is 10000 sq m therefore divide your area by this figure to get the result you require (see below) (defun c:aa (/ c a b) (command "style" "romans" "romans" 8 0.85 "" "" "" "" ) (setq os(getvar "osmode")) (setvar "osmode" 0) (SETQ p0 (GETPOINT "\n PICK A CLOSED AREA:")) (command "BPOLY" p0 "") (COMMAND "AREA" "E" "L" ) (COMMAND "ERASE" "L" "") (COMMAND "REDRAW" ) (SETQ A (GETVAR "area")) (SETQ B (GETPOINT "\n PICK A POINT TO WRITE AREA:")) (SETQ C (RTOS (/ a 10000)) (COMMAND "COLOR" 3 ) (SETQ Text (strcat "Area=" C)) (COMMAND "TEXT" B "0" (strcat text "ha")) (COMMAND "COLOR" "BYLAYER" ) (command "style" "italict" "" 0 0.85 "" "" "" "" ) (setvar "osmode" os) (setq w nil ) )
    1 point
  12. hi your lisp is related to area, but what does segment mean? 1.localize variable 2.using cond or and instead of many if if if 3.entmake entity is faster 4.FWIW (setvar 'luprec [color="red"]2[/color]) ([color="blue"][b]rtos[/b][/color] number 2 [color="red"]2[/color]) (defun artos (x / u i) [color="green"]; Area Real To String - metric [/color] ;hanhphuc (eval (cons 'strcat (reverse (list (setq x (float x) u (if (< (setq i (/ (abs x) 1e+4)) 0.1) " m\U+00B2" " ha")) (cons '[color="blue"][b]rtos[/b][/color] (if (= u " ha") (list (/ x 1e+4) 2 ([color="blue"][b]cond[/b][/color] ((< i 1.0) 3)((< i 10.0) 2)((< i 100.0) 1) (t 0))) (list x 2 (if (< (abs x) 100.) 1 0 )) ) ) ) ) ) ) ) ;example (command "_TEXT" dtxcent "90" (artos (getvar 'area))) test (defun foo (l) (if (< 0.001 (car l)) (foo (setq l (mapcar ''((x) (princ (strcat "\n" (rtos x 2) " --> " ([color="blue"]artos[/color] x))) (/ x 10.)) l)) ) ) ) [color="green"];test[/color] ([color="blue"]foo[/color] '(987654321 123456789 100000000)) [color="purple"]987654321.000 --> 98765 ha 123456789.000 --> 12346 ha 100000000.000 --> 10000 ha 98765432.100 --> 9877 ha 12345678.900 --> 1235 ha 10000000.000 --> 1000 ha 9876543.210 --> 988 ha 1234567.890 --> 123 ha 1000000.000 --> 100 ha 987654.321 --> 98.8 ha 123456.789 --> 12.3 ha 100000.000 --> 10.0 ha 98765.432 --> 9.88 ha 12345.679 --> 1.23 ha 10000.000 --> 1.00 ha 9876.543 --> 0.988 ha 1234.568 --> 0.123 ha 1000.000 --> 0.100 ha 987.654 --> 988 m² 123.457 --> 123 m² 100.000 --> 100 m² 98.765 --> 98.8 m² 12.346 --> 12.3 m² 10.000 --> 10.0 m² 9.877 --> 9.9 m² 1.235 --> 1.2 m² 1.000 --> 1.0 m² 0.988 --> 1.0 m² 0.123 --> 0.1 m² 0.100 --> 0.1 m² 0.099 --> 0.1 m² 0.012 --> 0.0 m² 0.010 --> 0.0 m² 0.010 --> 0.0 m² 0.001 --> 0.0 m² 0.001 --> 0.0 m²[/color] example: ([color="blue"]defun[/color] c:atest (/ [color="red"][b]en p[/b][/color]) [color="green"]; localized variables[/color] ([color="blue"]while[/color] [color="green"]; loop if entity is selected [/color] ([color="blue"]and [/color]([color="blue"]setq[/color] en ([color="blue"]car[/color] ([color="blue"]entsel[/color] [color="purple"]"\nPick area entity.. "[/color]))) [color="green"]; select 2D entity [/color] ([color="blue"]vlax-property-available-p[/color] ([color="blue"]vlax-ename->vla-object[/color] en) 'Area) [color="green"]; check whether has 'area' property[/color] ([color="blue"]setq[/color] p ([color="blue"]getpoint[/color] [color="purple"]"\nSpecify text placement point.. "[/color])) [color="green"]; locate text insertion point [/color] ([color="blue"]entmakex[/color] ([color="blue"]list[/color] '(0 . [color="purple"]"TEXT"[/color])[b][color="red"] '( 8 . [/color][color="purple"]"leg-area"[/color][color="red"] )[/color] [/b][color="green"] ; to avoid command call [/color] ([color="blue"]cons[/color] 1 ([color="blue"]artos[/color] [color="blue"](vlax-curve-getArea[/color] en ))) [color="green"]; convert area value to string using sub function [/color] ([color="blue"]cons[/color] 10 ([color="blue"]trans[/color] p 1 0)) [color="green"]; text insertion point[/color] ([color="blue"]cons[/color] 50 (* [color="blue"]pi[/color] 0.5 )) [color="green"]; angle 90d[/color] ([color="blue"]cons[/color] 40 ([color="blue"]getvar[/color] 'textsize)) [color="green"]; text height, command: textsize[/color] ) ) ) ) ([color="blue"]princ[/color]) )
    1 point
×
×
  • Create New...