Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/09/2024 in all areas

  1. Something like this. Extra properties to be added as needed. (vl-load-com) (defun drawLine (p1 p2) (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; http://www.lee-mac.com/round.html ;; Round Up - Lee Mac ;; Rounds 'n' up to the nearest 'm' (defun LM:roundup ( n m ) ((lambda ( r ) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r)) ((+ n (- m r))))) (rem n m)) ) ;; Round Down - Lee Mac ;; Rounds 'n' down to the nearest 'm' (defun LM:rounddown ( n m ) ((lambda ( r ) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r m)) ((- n r)))) (rem n m)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; This function allows the user to select a segment of polyline. ;; The function returns the segment as though it were a line. As if the polyline was exploded. (defun nentselpl ( / res sel type sel_pt pl par start_ end_) (setq sel (entsel "\nSelect ployline: ")) (setq pl (car sel)) (setq type (cdr (assoc 0 (entget pl)))) (if (wcmatch type "*POLYLINE") (progn (setq sel_pt (cadr sel)) (setq sel_pt (vlax-curve-getClosestPointTo (vlax-ename->vla-object pl) sel_pt)) ;; parameter -> this tells you the index of the segment. And where on the segment the point is (setq par (vlax-curve-getparamatpoint pl sel_pt)) ;; (vlax-ename->vla-object pl) ;; start point of the segment (setq start_ (vlax-curve-getPointAtParam (vlax-ename->vla-object pl) (LM:rounddown par 1.0))) (setq end_ (vlax-curve-getPointAtParam (vlax-ename->vla-object pl) (LM:roundup par 1.0))) (setq res (list (cons 10 start_) (cons 11 end_) (cons 8 (cdr (assoc 8 (entget pl)))) ;; layer ;; ... add extra properties if you wish )) ) nil ) res ) ;; TEST function (defun c:nentselpl ( / sel) (setq sel (nentselpl)) (princ sel) (drawLine (cdr (assoc 10 sel)) (cdr (assoc 11 sel)) ) (princ) )
    2 points
  2. This is what I use to get a list of pline points. I think I got it from Lee-mac. (setq plent (entsel "\nPick pline ")) (if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent)))))) For any point use (nth x co-ord) note 1st point x=0, so for 2 points only x=1
    2 points
  3. @barristann A simple function commonly called MASSOC, which returns a list of all DXF codes of a certain prefix. There ae several variations of this function out there. (defun Massoc (el dxf) (vl-remove-if 'null (mapcar (function (lambda (x)(if (= (car x) dxf) x nil))) el) ) ) ;;Example that will return the 2nd vertex of a selected polyline. (cdr (cadr (Massoc (entget (car (entsel))) 10)))
    2 points
  4. Thank you pkenewell, BIGAL, and Steven P. All of these methods work. These lessons are invaluable to me!
    1 point
  5. Hello Dszlapka, welcome in the forum! I am in vacation right now, I can't test it, but the "strcat" method should work. (defun c:KT_dlugosc ( / poly att) (while (and (setq poly (ssget "_+.:S:E" '((0 . "*LINE")))) (setq att (car (nentsel "\nSelect Attribute"))) (eq "AcDbAttribute" (vla-get-objectname (setq att (vlax-ename->vla-object att))) ) ) (vlax-put att 'TextString (strcat (rtos (vlax-curve-getDistAtParam (setq poly (ssname poly 0)) (vlax-curve-getEndParam poly) ) 2 0 ) "m") ) )(princ) ) Please try this code and post a feed-back. Post the error message you get, for sure someone will be able to fix it!
    1 point
  6. and third option, if the polyline only has 2 points on it, can try reverse, look at it 'backwards' (if (setq ss (ssget ":L")) (progn (setq x 0) (setq ename (ssname ss x)) (setq elist (entget ename)) (setq pt (cdr(assoc 10 (reverse elist)))) ) ;; progn ) ;; if
    1 point
  7. There are 2 variables that control this action ATTREQ & ATTDIA. ATTREQ will allow or stop input of attributes. ATTDIA controls the dcl display You home work is have a look at help, HINT the values are 0 or 1 using (setvar 'ATTREQ x)
    1 point
  8. Try this (defun c:hcol ( / colobj lay x obj ss ang) (setq colObj (vlax-create-object (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2)))) (vla-setRGB colObj 120 120 120) (setq ang 100) (setq ang (* pi (/ ang 180.0))) ; convert to radians (setq lay (cdr (assoc 8 (entget (car (entsel "\nPick an object for layer ")))))) (setq ss (ssget "X" (list (cons 0 "HATCH")(cons 8 lay)))) (if (= ss nil) (alert "No hatches detected") (progn (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (vlax-put obj 'TrueColor colobj) (vlax-put obj 'PatternScale 1.333) (vlax-put obj 'PatternAngle ang) ) ) ) (princ) )
    1 point
  9. Ok start in a layout with 210x297 rectang in a no plot layer, starting at 0,0 that is an A4 sheet, You need to know the hard clip limits as its A4 I would use 6mm. So draw a new rectang say layer "Title", start at 6,6 upper right 204,291. Draw a line 6,26 to 204,26 this make a box where you will draw more stuff like project name, sheet number and so on. Save the dwg as say A4. You just need to go into the mview do say Z E, you will see your drawing objects that are in model space. You need to set a scale, a couple of ways 1st zoom in roughly to where you want at a suitable view. I am not using word Scale that is next, you can dbl click on out side of wviewport click on view port and you should in later versions of Acad get a scale list choos what you want, change if necessary, ok similar if you turn on the Toolbar viewport when you go inside a viewport a number will appear that is current scale you can type over that number, for us working in metres a number like 4 or 5 etc this is 1000/scale 1:250 1:200. Ok last step click on viewport right click+SHIFT on mouse select lock viewport, this stops accidently rescaling in the viewport. 3rd method is to use Zoom 4XP that again would be 1:250. An example A4 landscape.
    1 point
  10. So the result desired is a Latitude & Longitude, not X Y, there is various programs out there that will do that, the most important issue is that you have to set the world zone for where you are else the result will be pretty useless. Yes that is why this sort of thing is in CIV3D.
    1 point
×
×
  • Create New...