Coordinate blocks distance measurement

Coordinate blocks distance measurement

alxnds5
Enthusiast Enthusiast
2,314 Views
13 Replies
Message 1 of 14

Coordinate blocks distance measurement

alxnds5
Enthusiast
Enthusiast

Hello, I'm wondering if someone can help me. I've created coordinate blocks in a drawing I'm working on but I need the distance between the 2 blocks. Is there any command that will provide the x and y distances between the two? I need to account for both distance and sum them up.

 

This needs to be done for a lot of blocks so I'm wondering if there is a table that can also be extracted for AutoCAD.

 

 

0 Likes
2,315 Views
13 Replies
Replies (13)
Message 2 of 14

TheCADnoob
Mentor
Mentor
0 Likes
Message 3 of 14

alxnds5
Enthusiast
Enthusiast

I am using data extraction currently and thereafter formulating an equation that will find the overall length (account for x and y differences) but I'm wondering if there is a faster method as I have close to 100 blocks.

0 Likes
Message 4 of 14

john.vellek
Alumni
Alumni

Hi @alxnds5,

 

I see that you are visiting as a new member to the AutoCAD forum. Welcome to the Autodesk Community!

 

 Take your data extraction and drop it into an Excel spreadsheet.  Form there you should be able to do the math failry easily.

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 5 of 14

Kent1Cooper
Consultant
Consultant

@alxnds5 wrote:

.... I need the distance between the 2 blocks. .... I need to account for both distance and sum them up. ....


(defun C:TEST (/ blksel1 blksel2)
  (setq
    blksel1 (entsel "\nSelect one Block: ")
    blksel2 (entsel "\nSelect other Block: ")
    delta (mapcar '- (cdr (assoc 10 (entget (car blksel1))))  (cdr (assoc 10 (entget (car blksel2)))))
  ); setq
  (prompt
    (strcat
      "\nSum of X & Y distances between Blocks = "
      (rtos (+ (abs (car delta)) (abs (cadr delta))))
      "."
    ); strcat
  ); prompt
  (princ)
); defun

That's just the summation-of-XY part, not the further stuff [e.g. table].  If I've misunderstood, give more detail about what you need, what steps the User would take, the nature of the Blocks, etc.

 

Kent Cooper, AIA
Message 6 of 14

alxnds5
Enthusiast
Enthusiast

Hi Kent,

 

I tried the code but I'm not able to get anything, not sure if there is something additional I have to input. To give you a better idea of what I need I've attached a sample image, so basically what I need is to distance (sum of x and y) from the coordinates up top to the box labeled "1" at the bottom. 

 

For example a method that would calculate distance using the coordinates (52,470) to the coordinates at the bottom (71,20). I have to do this repeatedly with many columns so anything to expedite the process and make it more effective would be great.

IMAGE.PNG

0 Likes
Message 7 of 14

Kent1Cooper
Consultant
Consultant

@alxnds5 wrote:

.... I tried the code but I'm not able to get anything....

 


 

Are they not Blocks?  If they are, are their insertion points at the locations you want to measure between?  When you try it, what do  you get?  Any error messages?

Kent Cooper, AIA
0 Likes
Message 8 of 14

alxnds5
Enthusiast
Enthusiast

I created a coordinate block  (in green) and placed them at different points as you can see on the image. You are correct I want the distance between them. So distance between 1 to box 1, 2 to box 1 and 3 to box 1 (x and y included, so the perpendicular path not just the linear).

 

Upon pasting the code I cannot pick the block, perhaps I don't know how to use the code. I apologize I'm not too familiar with coding through AutoCAD.

 

0 Likes
Message 9 of 14

Kent1Cooper
Consultant
Consultant

@alxnds5 wrote:

.... 

Upon pasting the code I cannot pick the block, perhaps I don't know how to use the code. I apologize I'm not too familiar with coding through AutoCAD.


 

The code defines a command name.  It doesn't "do the work" until you call for that command.  If you're just pasting the code into a drawing, then you still need to type TEST to run it.  If it does what you want, save it as a file with a .lsp filetype ending that you can then APPLOAD in any drawing, and change that TEST command name to something more meaningful.

Kent Cooper, AIA
0 Likes
Message 10 of 14

alxnds5
Enthusiast
Enthusiast

I was able to get it, thank you so much Kent. Do you know of any command that would compile the data in this case the distances in a table format?

0 Likes
Message 11 of 14

Kent1Cooper
Consultant
Consultant

@alxnds5 wrote:

.... Do you know of any command that would compile the data in this case the distances in a table format?


 

I don't, and I've only rarely used Tables, and never in AutoLisp.  Search the Customization Forum, and you may find something that builds a Table from collected information.

Kent Cooper, AIA
0 Likes
Message 12 of 14

john.vellek
Alumni
Alumni

HI @alxnds5,

 

This should be workable in Excel. You capture all the blocks with their insertion points and you can perform the same kind of math that @Kent1Cooper's routine does for the two individual blocks.

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 13 of 14

alxnds5
Enthusiast
Enthusiast

I'm not quite sure that would work considering its several blocks connecting to one main block. They don't interconnect among one another so I don't know how I would be able to get an accurate total distance. As far as extracting data, I don't know if these distances would be able to be extracted apart from manually writing each one manually in an excel.

0 Likes
Message 14 of 14

alxnds5
Enthusiast
Enthusiast

I have one last question, I'm sorry. Is it possible to modify your code so that there is one main block chosen and thereafter pick multiple blocks that have a path to the main block?, that way it adds all the distances to that one main block.

0 Likes