Question about using VBA script in Excell to automate single-line generation.

Question about using VBA script in Excell to automate single-line generation.

Jason_SniderWUKJ8
Contributor Contributor
290 Views
2 Replies
Message 1 of 3

Question about using VBA script in Excell to automate single-line generation.

Jason_SniderWUKJ8
Contributor
Contributor

I've been reading that this is possible and have seen a few examples on reddit and other websites. I'm trying to put together one of the scripts for myself to help save me time in the long run. I've watched a few tutorials and read a bunch but I'm still running into an issue getting off to a full sprint.

 

My question is as follows: I should have all possible locations mapped out in the layout that I can then export coordinates from for the individual text blocks, device blocks, and their position in the viewport and using this coordinate information to build my VBA script in excel? Or am I overthinking it?

 

Example below.

 

 Thanks for your help.

0 Likes
291 Views
2 Replies
Replies (2)
Message 2 of 3

Sea-Haven
Mentor
Mentor

If I understand your request, first the sample dwg had no viewports setup. You can get only objects from model space that are within a window the size of the viewport.  You use the trans function. to work out the window points based on the viewport.

 

A viewport has the following properties. Using (entget (car (entsel "\nPick viewport")))

 

PICK((-1 . <Entity name: de2c2e30>) (0 . "VIEWPORT") (5 . "3BDF7") (330 . <Entity name: da4e8e90>) (100 . "AcDbEntity") (67 . 1) (410 . "Detail") (8 . "WACHTER-LABELS") (100 . "AcDbViewport") (10 17.9844497372394 11.999999517336 0.0) (40 . 35.8910603099105) (41 . 23.8691006458669) (68 . 2) (69 . 2) (12 20.5584427374715 14.756579553713 0.0) (13 0.0 0.0 0.0) (14 0.5 0.5 0.0) (15 0.5 0.5 0.0) (16 0.0 0.0 1.0) (17 0.0 0.0 0.0) (42 . 50.0) (43 . 0.0) (44 . 0.0) (45 . 49.0016811663871) (50 . 0.0) (51 . 0.0) (72 . 1000) (90 . 819296) (1 . "") (281 . 0) (71 . 1) (74 . 0) (110 0.0 0.0 0.0) (111 1.0 0.0 0.0) (112 0.0 1.0 0.0) (79 . 0) (146 . 0.0) (170 . 0) (61 . 5) (348 . <Entity name: da4e9f90>) (292 . 1) (282 . 1) (141 . 0.0) (142 . 0.0) (63 . 250) (421 . 3355443) (361 . <Entity name: da554360>))

 

dxf 10 is centroid, 40 is length., 41 is width

 

So you get centroid and add 1/2 the width and length to work out the 2 corner points, then use (trans minpt 3 0) & (trans maxpt 3 0), this will give you the 2 corner points in model and you can use (ssget "WP" pts '((0 . "insert"))) to get say all the blocks then get insertion points and send to excel.

 

Hopefully all that makes sense. If correct provide a better sample dwg properly setup.

 

 

0 Likes
Message 3 of 3

devitg
Advisor
Advisor

@Jason_SniderWUKJ8 The are no viewports at the layouts in Paper Space, neither are Text Blocks or Device  Block at Model Space

 

 

0 Likes