Automation of Block Assignment

Automation of Block Assignment

frjuniornogueira
Explorer Explorer
738 Views
7 Replies
Message 1 of 8

Automation of Block Assignment

frjuniornogueira
Explorer
Explorer

Hello everyone,

First of all, thank you for your feedback. I have a situation I’d like to automate, but I’m not sure if it's possible.

I have some polylines with blocks at their vertices, and these blocks come in three types:

  • At the beginning of a polyline, if there is only one, the block is type 1. (photo)

 

frjuniornogueira_1-1726006041046.png

 

 

  • If there are two at the beginning, the block will be type 3. (photo)

frjuniornogueira_2-1726006109206.png

 

 

  • If the polyline makes a sharp angle, the block will also be type 1.

frjuniornogueira_3-1726006155676.png

 

  • If the angle is right or has a slight angle, the block will be type 2.

frjuniornogueira_4-1726006247162.png

 

I'm attaching a DWG file as an example of how it should look. Is it possible to create a command to automate this process? The block is already placed at the polyline vertices; it just needs to be assigned the correct type in the attribute.

0 Likes
739 Views
7 Replies
Replies (7)
Message 2 of 8

Sea-Haven
Mentor
Mentor

Two comments "already placed at the polyline vertices" the 2 TYPE-2 on left are at 1/3 point not vertice.

 

The Type-1 red pline does not appear to have any angle change so should be TYPE-2.

 

It may need to walk through the plines two times, as need to check for a gap but not be an end point. 

 

Like others will have a think about it. 

 

It may be easier to insert the blocks rather than try to amend them. Insert to vertices do 1st and so on. Then can do add blocks at 1/3 rd points.

0 Likes
Message 3 of 8

frjuniornogueira
Explorer
Explorer

It may be easier to insert the blocks rather than try to amend them. Insert to vertices do 1st and so on. Then can do add blocks at 1/3 rd points.


It's not possible, the blocks will always be in the project, that was the reason I thought it wouldn't be possible to do the automation.

I couldn't understand your other questions.

0 Likes
Message 4 of 8

Sea-Haven
Mentor
Mentor

This should explain my questions.

SeaHaven_0-1726106076064.png

 

What I was suggesting was to do the check when inserting the block so it gets correct Attribute at that stage, that would be my way to do it, maybe a couple of options but in one code. 

 

The 2 blocks at say a 1/3rd spacing would be obvious that they are Type-2. So a separate function asking for ratio 2, 3, 4 and so on within a pline or line segment. 

 

Vertex second function.

 

 

 

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/automation-of-block-assignment/td-p/13012643

(defun c:ins2 ( / oldsnap num start end pt lst )

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setvar 'attreq 1)
; (setq obj (vlax-ename->vla-object (car (entsel "\nPick line or pline object "))))
(setq obj (vlax-ename->vla-object (car (entsel "\nPick line  "))))

; (setq objtyp (vlax-get obj 'objectname))
; next version check for pline segment

(setq num (getint "\Enter the number of segments "))

(setq start (vlax-curve-getstartPoint obj))
(setq end (vlax-curve-getEndPoint obj))
(setq ang (angle start end))
(setq spac (/ (distance start end) num))
(setq lst '() dist 0)
(repeat (- num 1)
(setq pt (polar start ang (setq dist (+ dist spac))))
(setq lst (cons pt lst))
)
(foreach pt lst
(setq pt (mapcar '+ pt (list 0.0 -2.95 0.0)))
(command "-Insert" "block_teste" pt 1 1 0 "TYPE-2")
)

(setvar 'osmode oldsnap)
(princ)
)

(defun c:ins1 ( / )
(alert "to be done")
; vertice points with or without gap.
)

 

 

Again starting with no block and inserting starting to get somewhere. Need to adjust insertion point.

SeaHaven_0-1726125068671.png

The remaining vertices will be easier to do.

 

0 Likes
Message 5 of 8

frjuniornogueira
Explorer
Explorer

 

Again starting with no block and inserting starting to get somewhere. Need to adjust insertion point.

SeaHaven_0-1726125068671.png

The remaining vertices will be easier to do.

 


Can insert it at any vertex, this won't be an issue. It just needs to check if there are two polylines.

 

0 Likes
Message 6 of 8

frjuniornogueira
Explorer
Explorer

SeaHaven_0-1726106076064.png

 

What I was suggesting was to do the check when inserting the block so it gets correct Attribute at that stage, that would be my way to do it, maybe a couple of options but in one code. 

 

The 2 blocks at say a 1/3rd spacing would be obvious that they are Type-2. So a separate function asking for ratio 2, 3, 4 and so on within a pline or line segment. 

 The example I showed you is correct. Type 02 should be placed where there are no sharp curves and can never be used more than twice in a row. Whenever you insert two, the next one must be Type 01.
That was exactly what made me think it wouldn't be possible.

0 Likes
Message 7 of 8

Sea-Haven
Mentor
Mentor

"Whenever you insert two, the next one must be Type 01." When getting pline vertices can keep count and do its "3rd" insert, so put Type-1 not Type-2.

 

Still working on it. Its happy hour time.

0 Likes
Message 8 of 8

frjuniornogueira
Explorer
Explorer

I understand, but this is the standard, it should be this way.

0 Likes