need to store 2 node point of 1 bock in 2 different variable

need to store 2 node point of 1 bock in 2 different variable

Anonymous
Not applicable
1,809 Views
12 Replies
Message 1 of 13

need to store 2 node point of 1 bock in 2 different variable

Anonymous
Not applicable

Hi,

I have a 3D rectangular block. It is having 2 node points. I want to store coordinates of each node point in different variable say a and b.

Thanks,
Kishan

0 Likes
1,810 Views
12 Replies
Replies (12)
Message 2 of 13

devitg
Advisor
Advisor

Hi @Anonymous  so simple 

 

(setq osmode (getvar 'osmode))
(setvar 'osmode 😎 ; to snap at the node
(setq node-1 (Getpoint "\n pick at node-1" ))
(setq node-2 (getpoint node-1 "\n Pick at node-2 "))
(setvar 'osmode osmode)
Message 3 of 13

devitg
Advisor
Advisor

 

thais line should be 

(setvar 'osmode ( 1+ 7   ))   ; to snap at the node

 

if not it show the smiley face  

Message 4 of 13

pbejse
Mentor
Mentor

@Anonymous wrote:

Hi,

I have a 3D rectangular block. It is having 2 node points. I want to store coordinates of each node point in different variable say a and b.


 

Are the 2 node points randomly located per 3D rectangular block? 

 

 

0 Likes
Message 5 of 13

Kent1Cooper
Consultant
Consultant

@pbejse wrote:
....

Are the 2 node points randomly located per 3D rectangular block? 


To which I would add:

 

Is the idea that the User selects a Block insertion, anywhere on it [not necessarily at one of the Points], and the code finds where the two Points are, based on the Block definition?

 

What kinds of variabilities are to be expected?  Are the Blocks inserted at different rotation angles, and/or with different scale factors?  In different Coordinate Systems?

Kent Cooper, AIA
0 Likes
Message 6 of 13

Anonymous
Not applicable

Actually I was looking for a program like below,

 

I have a 3d rectangular block created by wblock command, the block has two node points A and B, And I need to store the coordinates of this node points in two different variable. WHEN I SELECT THIS BLOCK THESE NODE POINTS WILL AUTOMATICALLY GET STORE IN 2 DIFFERENT VARIABLES LETS SAY node-1 and node-2.

 

Thank you in Advance,

KISHAN

20210612_004743.jpg

0 Likes
Message 7 of 13

Anonymous
Not applicable

@devitg wrote:

Hi @Anonymous  so simple 

 

 

(setq osmode (getvar 'osmode))
(setvar 'osmode  ; to snap at the node
(setq node-1 (Getpoint "\n pick at node-1" ))
(setq node-2 (getpoint node-1 "\n Pick at node-2 "))
(setvar 'osmode osmode)

 



@devitg wrote:

Hi @Anonymous  so simple 

 

 

(setq osmode (getvar 'osmode))
(setvar 'osmode  ; to snap at the node
(setq node-1 (Getpoint "\n pick at node-1" ))
(setq node-2 (getpoint node-1 "\n Pick at node-2 "))
(setvar 'osmode osmode)

 


Thank you So much @devitg

0 Likes
Message 8 of 13

devitg
Advisor
Advisor

@Anonymous , a BLOCK is an ACAD entity, yours is, at least,  a CUBE as per geometry,   or a BOX  as per ACAD 

 

such entity has not NODES it have m ENDPOINTS, MIDPOINTS, INTERSECTION

 

(setq osmode (getvar 'osmode))
(setvar 'osmode (+ 1  32))  ; to snap  END, or to INTERSECTION 

(setq node-1 (Getpoint "\n pick at node-1" ))
(setq node-2 (getpoint node-1 "\n Pick at node-2 "))
(setvar 'osmode osmode)

 

 

0 Likes
Message 9 of 13

devitg
Advisor
Advisor

a best way 

 

(defun c:corners ()

(DEFUN GET-CORNERS  (/
                     CORNER-1
                     CORNER-2
                     OSMODE
                     )

  (SETQ OSMODE (GETVAR 'OSMODE))
  (SETVAR 'OSMODE (+ 1 32)) ; to snap to END, or to INTERSECTION 

  (SETQ CORNER-1 (GETPOINT "\n pick at corner-1"))
  (SETQ CORNER-2 (GETPOINT CORNER-1 "\n Pick at CORNER-2 "))


  (SETVAR 'OSMODE OSMODE)
  (LIST CORNER-2 CORNER-1)
  )


(setq corner-list (GET-CORNERS))

)
Message 10 of 13

Anonymous
Not applicable

Thank you for reply @devitg.

But I have one more question, let me share my drawing and let you know. 

0 Likes
Message 11 of 13

Sea-Haven
Mentor
Mentor

Perhaps

(setq obj (vlax-ename->vla-object (car (entsel "pick object "))))
(vla-GetBoundingBox obj 'minpoint 'maxpoint)
(setq pointmin (vlax-safearray->list minpoint))
(setq pointmax (vlax-safearray->list maxpoint))
Message 12 of 13

Anonymous
Not applicable

Hello @Sea-Haven ,

kghatkari_1-1623482731469.png

I have tried the Code which you have shared but I need program for coordinates of the points shown in red circle which can be stored in two variables. but I dont want to prompt user two time to select two points instead of this can we prompt one time to pick object same as given in your code.

Thanks in Advance,
Kishan

0 Likes
Message 13 of 13

hak_vz
Advisor
Advisor

Picking two points is the best option that assures correct result. Two points on the edge can  be calculated from the method presented by @Sea-Haven  (box diagonal that don't always connect box edges i.e. it connects points on diagonal of a bounding box), but it don't give exact result in all cases.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes