Jump to content

Recommended Posts

Posted

How to get all dxf codes 10 in LWPOLYLINE , Because for rectangl shape there are 4 codes 10 which indicate to start points.

 

((-1 . <Entity name: 7ee18ae0>) (0 . "LWPOLYLINE") 
(330 . <Entity name: 7ef05c10>) (5 . "49E1EC") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "HWS") (62 . 1) (6 . "Continuous")
(100 . "AcDbPolyline") (90 . 4) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0) ([color="red"]10 59.7148 -157.215[/color]) (40 . 0.0)
(41 . 0.0) (42 . 0.0) ([color="red"]10 63.4695 -157.215[/color]) (40 . 0.0) (41 . 0.0) (42 . 0.0) 
([color="red"]10 63.4695 -159.592[/color]) (40 . 0.0) (41 . 0.0) (42 . 0.0) 
([color="red"]10 59.7148 -159.592[/color]) (40 . 0.0) (41 . 0.0) (42 . 0.0) (210 0.0 0.0 1.0))

 

(setq a (entsel))

(setq b (entget (car a)))

(setq c (cdr (assoc 10 b))) I would get only the first only and if I repeated the same I would get the same.

 

Thanks.

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • Michaels

    11

  • Kerry Brown

    9

  • Lee Mac

    3

Top Posters In This Topic

Posted

Try massoc multi-assoc

 

;;----------------------------------------------------------------------------
(defun massoc (key alist / x nlist)
 (foreach x alist
   (if (eq key (car x))
     (setq nlist (cons (cdr x) nlist))
   )
 )
 (reverse nlist)
)

;;----------------------------------------------------------------------------

 

 

 

(setq c (massoc 10 b))

Posted

I may did something wrong or missed a thing !

 

(setq a (entsel))
(setq b (entget (car a)))
(setq c (massoc 10 b)) 
(vl-cmdf "_.line" c)

 

Can you please explain your defun to me, and why did you reverse the nlist at the end ?

 

Thanks,

Posted

The reverse is used because the cons in the loop adds each dxf10 as it is found to the start of the nlist.

We want the result to be in the order found, so ....

 

//------------

 

Why do you think passing a list of points to the line command will work ??

Posted

I made it manually through Autocad and I had the following.

 

(reverse(massoc 10 c))
((12651.5 6355.58) (12655.1 6355.58) (12655.1 6357.89) (12651.5 6357.89))

 

So how can I get each xy one by one?

Posted

Please clarify

So how can I get each xy one by one?

Posted

According to my selection which is (rectangl = LWPOLYLINE) I had the above points in brackets so I have isolate each

ucs (xy) to be able to draw a line with these points.

(([color="red"]12651.5[/color] [color="blue"]6355.58[/color]) ([color="red"]12655.1[/color] [color="blue"]6355.58[/color]) ([color="red"]12655.1[/color] [color="blue"]6357.89[/color]) ([color="red"]12651.5[/color] [color="blue"]6357.89[/color]))

Posted

So,

you want to use those points; translate from UCS to WORLD and draw a series of lines ??

Posted

YES. Just an idea for the moment. :)

 

And if something come up, I may re-dive again in the codes. :lol:

 

Best regards.

Posted

try this

 

Using :

;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;
;;;   (setq vertexList (list (list 0. 0. 0.)
;;;                          (list 200. 0. 0.)
;;;                          (list 200. 100. 0.)
;;;                          (list 0. 100. 0.)
;;;                    )
;;;         layerName  (getvar "CLAYER")
;;;   )
;;;   (kbub:EntmakePlineInUCS vertexList layerName 1)
;;;   vertexList points expressed in Current UCS
(defun kbub:entmakeplineinucs (l n c / dxf210)
 ;; Codehimbelonga kdub 2010.06.22
 (setq dxf210 (trans '(0 0 1) 1 0 t))
 (entmakex
   (append (list '(0 . "LWPOLYLINE")
                 '(100 . "AcDbEntity")
                 '(100 . "AcDbPolyline")
                 (cons 90 (length l))
                 (cons 70 c)                ; 1 closed : 0 open
                 (cons 8 n)
                 (cons 38 (caddr (trans (car l) 1 dxf210)))
                 (cons 210 dxf210)
           )
           (mapcar (function (lambda (pt) (cons 10 (trans pt 1 dxf210)))) l)
   )
 )
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
;;;

 

 

 

This will read the selected entity ( assumed a pline)

extract the dxf10 points

draw lines between the points translated fron UCS to WORLD

 

(setq a (entsel))
(setq b (entget (car a)))
(setq c (massoc 10 b))
(setq c-world (mapcar '(lambda (x) (trans x acucs acworld)) c))

(if (setq e (kbub:entmakeplineinucs c "0" 1))
 (progn (vla-explode (vlax-ename->vla-object e)) (entdel e))
)

Posted

Your codes are perfect, and how it's drawn a line since the entmakex is lwpolyline ?

 

And can I make a cross in the intersection of the forth lines as well ?

 

Thanks

Posted

Your codes are perfect, and how it's drawn a line since the entmakex is

lwpolyline ?

 

Thanks

^^^^ May I ask again ?

Posted

Have a look at my code, and see if you can tell me .

Posted

Another couple of 'massoc's as an example:

 

(defun massoc ( x lst )
 ;; © Lee Mac 2010
 (vl-remove-if-not
   (function
     (lambda (pair) (= x (car pair)))
   )
   lst
 )
)

 

(defun massoc ( x lst )
 ;; © Lee Mac 2010
 (if lst
   (if (= x (caar lst))
     (cons (car lst) (massoc x (cdr lst)))
     (massoc x (cdr lst))
   )
 )
)

Posted
Try massoc multi-assoc

 
;;----------------------------------------------------------------------------
(defun massoc (key alist / x nlist)
 (foreach x alist
   (if (eq key (car x))
     (setq nlist (cons (cdr x) nlist))
   ) )
 (reverse nlist))
;;----------------------------------------------------------------------------

(setq c (massoc 10 b))

 

This defun works great, But unfortunetly I do not understand how it implementing codes .

 

Could you please explain it to me ? ? ??

 

Thanks.

 

Michaels.

Posted

No, but I will correct any attempt that you make to explain it.

 

assume that b is the list in your first post.

 

Regards, Kerry

Posted
No, but I will correct any attempt that you make to explain it.

 

assume that b is the list in your first post.

Regards, Kerry

 

waw waw that was so so helpful :cry:

Posted

Please don't cry about it :-)

I'm being very helpful ... as you will realise when you've studied the code.

Posted
Another couple of 'massoc's as an example:

(defun massoc ( x lst )
 ;; © Lee Mac 2010
 (vl-remove-if-not
   (function
     (lambda (pair) (= x (car pair)))
   )
   lst
 ))

 

(defun massoc ( x lst )
 ;; © Lee Mac 2010
 (if lst
   (if (= x (ca[color="red"][b]a[/b][/color]r lst))
     (cons (car lst) (massoc x (cdr lst)))
     (massoc x (cdr lst))
   )  ))

 

Can you please explain to me the procedure of codes they are running ?

 

Thanks.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...