Jump to content

Nested Rectangle block corner points coordinates


Recommended Posts

Posted

I want To extract Nested Rectangle block corner points coordinates 

Find below imsge

IMG_20200428_004624.JPG

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • Praveen p

    8

  • hanhphuc

    7

  • Jonathan Handojo

    4

  • BIGAL

    2

Top Posters In This Topic

Posted Images

Posted

Need a dwg to look at task properly, if its the only pline in the block then easy.

Posted

I want to extract nested block coordinates by click the nested blick.

please give me lisp codes(hint)

please find the attachment dwg

nested block.dwg

Posted

No need to make new threads for the same question.

Posted
4 hours ago, Praveen p said:

I want to extract nested block coordinates by click the nested blick.

please give me lisp codes(hint)

please find the attachment dwg

nested block.dwg 52.13 kB · 0 downloads

 

The attached drawing is not very helpful as the block is not nested. It would be easier if you provided a sample drawing of blocks where this block is nested.

Posted
On 4/28/2020 at 3:17 AM, Praveen p said:

I want To extract Nested Rectangle block corner points coordinates 

Find below imsge

 

 

my $0.02

1.easiest way explode+ undo1, but useless if nested more than 1 level

2.Express Tool, command: NCOPY ,then get vertices (WCS coordinates) as usual

 

 

For Bricscad which no ET supported 

(defun c:nestpl (/ np enx l)
  ;hanhphuc 01.05.2020
  ;for Bricscad 
  ;uniform scale only & does not support dynamic block 
  
  (setvar 'pdmode 2)
  
  (if
    (setq np (nentselp "\nSelect nested : "))
    (and
    (setq enx (entget (car np)))
    (or
    (= (cdr (assoc 0 enx)) "LWPOLYLINE")
    (alert "Invalid LWPolyline entity!")
    )
    (setq l (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) enx)))
    (mapcar '(lambda (x) (entmakex (list '(0 . "POINT") (cons 10 x))))
      (if (= (length np) 4)
        (mapcar '(lambda (x)
                     (apply
                       'mapcar
                       (cons
                         '+
                         (cons
                           (mxv (caddr np) x)
                           (mapcar
                             '(lambda (x) (cdr (assoc 10 (entget x))))
                             (cadddr np)
                           )
                         )
                       )
                     )
                   )
                l
        )
        l
      )
    )
    (princ "\nDone!")
  )
  (progn (alert "Please pick LWPolyline!")
  (princ "\nhttps://www.cadtutor.net/forum/topic/70393-nested-rectangle-block-corner-points-coordinates/")
  )
 )
  (princ)
)

;; Matrix x Vector  -  Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n
 
(defun mxv ( m v )
    (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)

 

Posted
1 hour ago, hanhphuc said:

 

my $0.02

1.easiest way explode+ undo1, but useless if nested more than 1 level

2.Express Tool, command: NCOPY ,then get vertices (WCS coordinates) as usual

 

 

For Bricscad which no ET supported 


(defun c:nestpl (/ np enx l)
  ;hanhphuc 01.05.2020
  ;for Bricscad 
  ;uniform scale only & does not support dynamic block 
  
  (setvar 'pdmode 2)
  
  (if
    (setq np (nentselp "\nSelect nested : "))
    (and
    (setq enx (entget (car np)))
    (or
    (= (cdr (assoc 0 enx)) "LWPOLYLINE")
    (alert "Invalid LWPolyline entity!")
    )
    (setq l (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) enx)))
    (mapcar '(lambda (x) (entmakex (list '(0 . "POINT") (cons 10 x))))
      (if (= (length np) 4)
        (mapcar '(lambda (x)
                     (apply
                       'mapcar
                       (cons
                         '+
                         (cons
                           (mxv (caddr np) x)
                           (mapcar
                             '(lambda (x) (cdr (assoc 10 (entget x))))
                             (cadddr np)
                           )
                         )
                       )
                     )
                   )
                l
        )
        l
      )
    )
    (princ "\nDone!")
  )
  (progn (alert "Please pick LWPolyline!")
  (princ "\nhttps://www.cadtutor.net/forum/topic/70393-nested-rectangle-block-corner-points-coordinates/")
  )
 )
  (princ)
)

;; Matrix x Vector  -  Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n
 
(defun mxv ( m v )
    (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)

 

If rectangle is single line entity 

How to insert points and  its serial number

Posted

If rectangle is single line entity 

How to insert points and its serial number

Posted (edited)
4 hours ago, Praveen p said:

If rectangle is single line entity 

How to insert points and its serial number

 

Try to learn 🤔

you can add or modify anything you wanted in  (lambda (x) <where entmakex POINT resides>  )

 

Example 1: This will add incremental numbering start with "1"

(entmakex (list '(0 . "TEXT")(cons 10 x)(cons 40 (getvar 'textsize))(cons 1 (itoa (setq *index-num* (1+ (cond (*index-num*)(0)))) ))))

 use as 'x' as token (point coordinates)

 

 example 2: add circle

(command "CIRCLE" x 0.2)

 

do it yourself, trial and error see what happens :)

report back if error occurs good luck

 

 

 

 

 

 

Edited by hanhphuc
Posted

thank you sir

  Can you give this program without using mapcar AND lambda functions

 

Posted (edited)
18 hours ago, Praveen p said:

thank you sir

  Can you give this program without using mapcar AND lambda functions

(defun c:ppp ( / pt size )
(setq size 1.0) ;;change text height here or (getvar 'textsize)
(while 
(setq pt (getpoint "\nSpecify point or <Enter> to skip : ")) ;;variable 'pt' as token
;;; copied from previous, 'x' -> 'pt' 
(entmakex (list '(0 . "TEXT")(cons 10 (trans pt 1 0))(cons 40 size)(cons 1 (itoa (setq *index-num* (1+ (cond (*index-num*)(0)))) ))))
)
(princ)
)

 

Edited by hanhphuc
trans
Posted

thank you sir.

one more drawing attached to this mail.

please give me the codes for this drawing.

without using mapcar and lambda function give me the codes.

by click nested bock place the all point like shown in the drawing.

all codes must be in one program

SAMPLE.dwg

Posted

click & read this -> STRCAT

 

(setq *index-num* nil) ;; add this to initialize counting

 

before (1 . "1"

(cons 1 (itoa (setq *index-num* (1+ (cond (*index-num*)(0)))) ))

after (1 . "P-2";;prefix "P-" concatenation

(cons 1 (strcat "P-" (itoa (setq *index-num* (1+ (cond (*index-num*)(0)))) )))

 

 

Posted

thank you sir.

nested block is different with prvious block

in this drawing is different with previous drawing just check this drawing first sir.

text "p" is not constant some time it may be "A","B" TO "Z". AND some times text may be "A1",A2" OR "B1","B2"  so on

please give me full program without mapcar and lambda functions.

Posted

What's wrong with mapcar and lambda? They're very useful tools that even the most complex programs and codes use. I can almost bet that not even one of the LISP programs produced by the greatest programmers out there can exist without those. That's why they call it list processing.

 

Or is it because you don't actually know how they work and don't want them in there?

 

Why don't you describe the full situation that you actually want to achieve and post it at once instead of "P is not constant" or "here's one more dwg"? Otherwise the people who've helped you need to change their codes again and again.

Posted

sorry for that sir,

Actually i have different type of blocks,first block is different with second type of block first program codes not working on second block 

so thats why i asking it.

please give me codes.

thank you .

 

Posted
2 hours ago, Praveen p said:

thank you sir.

nested block is different with prvious block

in this drawing is different with previous drawing just check this drawing first sir.

text "p" is not constant some time it may be "A","B" TO "Z". AND some times text may be "A1",A2" OR "B1","B2"  so on

 

please give me full program without mapcar and lambda functions.

 

 

perhaps something LM:alpha++  ?

(LM:alpha++ "AZ") ; BA

(LM:num->col 1); A
(LM:num->col 26); Z
(LM:num->col 27); AA

example: repeat 235 increment 1+

(progn
(setq prefix "" i -1)
(repeat	(1+ (* 9 26))
  (terpri)
  (princ
    (strcat (setq prefix (if (zerop (rem (setq i (1+ i)) 9))
			   (LM:alpha++ prefix)
			   prefix
			 )
	    )
	    "-"(itoa (1+ (rem i 9)))
    )
  )
)
(princ)
)

output


A-1
A-2
A-3
A-4
A-5
A-6
A-7
A-8
A-9
B-1
B-2
B-3
B-4
B-5
B-6
B-7
B-8
B-9
C-1
C-2
C-3
C-4
C-5
C-6
C-7
C-8
C-9
D-1
D-2
D-3
D-4
D-5
D-6
D-7
D-8
D-9
E-1
E-2
E-3
E-4
E-5
E-6
E-7
E-8
E-9
F-1
F-2
F-3
F-4
F-5
F-6
F-7
F-8
F-9
G-1
G-2
G-3
G-4
G-5
G-6
G-7
G-8
G-9
H-1
H-2
H-3
H-4
H-5
H-6
H-7
H-8
H-9
I-1
I-2
I-3
I-4
I-5
I-6
I-7
I-8
I-9
J-1
J-2
J-3
J-4
J-5
J-6
J-7
J-8
J-9
K-1
K-2
K-3
K-4
K-5
K-6
K-7
K-8
K-9
L-1
L-2
L-3
L-4
L-5
L-6
L-7
L-8
L-9
M-1
M-2
M-3
M-4
M-5
M-6
M-7
M-8
M-9
N-1
N-2
N-3
N-4
N-5
N-6
N-7
N-8
N-9
O-1
O-2
O-3
O-4
O-5
O-6
O-7
O-8
O-9
P-1
P-2
P-3
P-4
P-5
P-6
P-7
P-8
P-9
Q-1
Q-2
Q-3
Q-4
Q-5
Q-6
Q-7
Q-8
Q-9
R-1
R-2
R-3
R-4
R-5
R-6
R-7
R-8
R-9
S-1
S-2
S-3
S-4
S-5
S-6
S-7
S-8
S-9
T-1
T-2
T-3
T-4
T-5
T-6
T-7
T-8
T-9
U-1
U-2
U-3
U-4
U-5
U-6
U-7
U-8
U-9
V-1
V-2
V-3
V-4
V-5
V-6
V-7
V-8
V-9
W-1
W-2
W-3
W-4
W-5
W-6
W-7
W-8
W-9
X-1
X-2
X-3
X-4
X-5
X-6
X-7
X-8
X-9
Y-1
Y-2
Y-3
Y-4
Y-5
Y-6
Y-7
Y-8
Y-9
Z-1
Z-2
Z-3
Z-4
Z-5
Z-6
Z-7
Z-8
Z-9
AA-1

and so on..

AA-9
...
...
AB-1
...
...
AB-9
...
...
AC-1
...
...
etc..


 

 

 

Posted (edited)
1 hour ago, Praveen p said:

sorry for that sir,

Actually i have different type of blocks,first block is different with second type of block first program codes not working on second block 

so thats why i asking it.

please give me codes.

thank you .

 

 

as i already mentioned :
STRCAT

have you tried it?

 

once you understand the usage of the function, then you won't ask for help for the next 3rd , 4th etc. different block anymore .. :)

learning is the key!!

 

 

p/s: command BEDIT if there's only line entity you can command PEDIT select Multiple JOIN as LWPOLYLINE

then you can use LISP c:nestpl for the rest of blocks

 

Edited by hanhphuc
comment bedit
Posted

"please give me codes." Sometimes if you keep adding then you may have to pay for service.

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...