Intelligent dynamic block

Intelligent dynamic block

sam_safinia
Advocate Advocate
832 Views
5 Replies
Message 1 of 6

Intelligent dynamic block

sam_safinia
Advocate
Advocate

Hi all.

I'm going to use lisp and dynamic block to get more intelligent block out of my existing db with using lisp routine. I have a straight db of a pipe and elbow that they got same range of size. I'm wondering how can we set our db insertion command within a routine to do one of these:

1. Remember last selected size of pipe db when want to add a elbow at the end of pipe

2. or hover over db(or asking to select the inserted pipe) then it just choose the appropriate size intelligently. 

 

Thanks

0 Likes
Accepted solutions (1)
833 Views
5 Replies
Replies (5)
Message 2 of 6

hmsilva
Mentor
Mentor

Hi s_plant,

are all the pipes dynamic blocks also?

 

Post a sample dwg, if possible.

 

Henrique

EESignature

0 Likes
Message 3 of 6

sam_safinia
Advocate
Advocate

Henrique,

 

Here is a dumbed down version of my DB!

 

As you can see, when I start my pipe route with a piece of pipe of D=50 and then afterward when adding fitting or pipe again, I want whether 

1. my second DB (here elbow) get D=50 as a default or

2. If it is possible, asking for the item which I want to connect to. Then by picking the pipe, it reads the pipe size from dynamic block data table.

(not sure explain it clearly!?)

 

I have read Lee_mac posts in regard to access to DB data table but did not get the right idea,

 

 

0 Likes
Message 4 of 6

hmsilva
Mentor
Mentor
Accepted solution

Hi s_plant,

using Lee's 'Get Dynamic Block Property Value' and 'Set Dynamic Block Property Value' It should be easy to accomplish...

 

But, to insert the next block, you should build your DymBlock library with a 'similar' insertion point, for example, at the pipe axis.

 

Using Lee's 'Get Dynamic Block Property Value' we need to supply two arguments, the block name and the property name, ex.

 

(defun c:demo ()
    (if (and (setq esel (entsel))
             (setq sel (car esel))
             (setq obj (vlax-ename->vla-object sel))
             (vlax-property-available-p obj 'IsDynamicBlock)
             (eq (vla-get-IsDynamicBlock obj) :vlax-true)
             (setq propval (LM:getdynpropvalue obj "Pipe Size"))
             (setq lastobj (entlast))
        )
        (progn
            (command "_.insert" .....)
            (if (and (setq objlast (entlast))
                     (not (eq lastobj objlast))
                     (setq objlast (vlax-ename->vla-object objlast))
                     (vlax-property-available-p objlast 'IsDynamicBlock)
                     (eq (vla-get-IsDynamicBlock objlast) :vlax-true)
                )
                (LM:setdynpropvalue objlast "Pipe Size" propval)
                )
            )
        )
    )

 

Hope this helps,
Henrique

EESignature

Message 5 of 6

sam_safinia
Advocate
Advocate

Henrique,

 

This code is working fine for me.


I test it today although it was old thread...I owed you a BIG thanks 🙂

0 Likes
Message 6 of 6

hmsilva
Mentor
Mentor

@s_plant wrote:

Henrique,

 

This code is working fine for me.


I test it today although it was old thread...I owed you a BIG thanks 🙂


You're welcome, s_plant
Glad I could help

Henrique

EESignature

0 Likes