Jump to content

Dynamic Block. Help please.


titoprax

Recommended Posts

Hello.

I am Spanish first of all ask forgiveness for my bad English.

Working in a fire protection company.

The software we use is autocad 2009.

For the design and creation of pipes for fire protection, we have created a dynamic block, with whom we have helped to improve work ... But we found a problem when it comes to counting those blocks.

The command EATTEXT is quite practical, since we determined the total number of blocks but equal does not help us to be able to modify the attribute. Problem that occurs with an option to qselect with which it is not possible to select those blocks that have the same attribute ...

My question is this:

You can modify the command EATTEXT so that once we have counted all the blocks can alter its attribute from the table that creates the command EATTEXT?

 

I put an example:

Imagine a building with 1000 doors. All these doors are dynamic block with attributes.

I would like to know how many doors the same distance there, as they have the same size, and so on.

With EATTEXT thanks to a table gives us all this information, but does not allow us to change from that table.

To do this we have to go to commands ATTOUT and ATTIN.

Did not you could improve the command EATTEXT with some LIST?

Is there any better way to achieve this step?

 

Thanks and forgiveness for my bad English.

Link to comment
Share on other sites

Ok, here I include the dynamic block for its examineis.

The dynamic block has a length AB and two other smaller lengths AC and CB. But an attribute (Name) inside the triangle, this attribute is to differentiate one kind of another.

The following file is an example.

The idea in this example is the following:

We have several dynamic blocks, they all have different lengths and they are all the same dynamic block.

Some are of equal length AB. But longitude A-C-C and B are different.

The idea is:

Knowing the No. exact same dynamic block with distances AB, AC and CB.

Once we know the exact N th power assign a number in the attribute.

Example:

Dist. AB: 8 AC: 3 CB: 5 Number: 15 Name (1)

Dist. AB: 15 AC: 10 BC: 5 Number: 5 Name (2)

 

Once finalized. The dynamic that will block attribute defined: 1.2, 30, 50, etc.

Dynamic Block II.dwg

Dynamic Block (Ensayos).dwg

Link to comment
Share on other sites

Seems it works (sort distances and print report in text screen):

 

(defun c:dycnt(/ dySet prLst rpLst lLen)

(vl-load-com)

(defun #Asmi_Extract_Dynamic_Blocks(SelSet NameList / bCnt eCnt cBl eBl oSet)
 (if(and SelSet NameList)
   (progn
     (setq bCnt 0
    NameList(mapcar 'strcase NameList)
    eCnt(sslength SelSet)
    oSet(ssadd)
    ); end setq
     (repeat eCnt
(setq cBl(vlax-ename->vla-object
	   (setq eBl(ssname SelSet bCnt))))
(if
  (and
   (= "AcDbBlockReference"(vla-get-ObjectName cBl))
   (vlax-property-available-p cBl 'EffectiveName)
   (member(strcase(vla-get-EffectiveName cBl))NameList)
   ); end and
  (ssadd eBl oSet)
 ); end if
(setq bCnt(1+ bCnt))
      ); end repeat
     );end progn
   ); end if
 oSet
 ); end of #Asmi_Extract_Dynamic_Blocks


(defun #Asmi_Get_Dynamic_Property(Block Property / oVal)
 (if(= 'ENAME(type Block))
   (setq Block(vlax-ename->vla-object Block))
   ); end if
 (if(= :vlax-true(vla-get-IsDynamicBlock Block))
   (foreach p(vlax-safearray->list
	(vlax-variant-value
	  (vla-GetDynamicBlockProperties Block)))
     (if(=(strcase Property)(strcase(vla-get-PropertyName p)))
(if(vl-catch-all-error-p
     (setq oVal(vl-catch-all-apply
		 'vla-get-Value(list p))))
  nil
  (setq oVal(vlax-variant-value oVal))
  ); end if
); end if
     ); end foreach
   ); end if
 oVal
 ); end of #Asmi_Get_Dynamic_Property

 (defun #Asmi_Set_to_List(Sel_Set VLA / Out)
 (setq Out
 (vl-remove-if 'listp
   (mapcar 'cadr(ssnamex Sel_Set))))
    (if VLA
       (mapcar 'vlax-ename->vla-object Out)
      Out
      ); end if
   ); end of #Asmi_Set_to_List


 (if
   (and
     (setq dySet(ssget "_X" '((0 . "INSERT"))))
     (setq dySet
     (#Asmi_Extract_Dynamic_Blocks dySet
         '("Despiece (Prueba 03)")))
     ); end if
   (progn
     (foreach bl(#Asmi_Set_to_List dySet T)
(setq prLst(cons
	      (list
		(#Asmi_Get_Dynamic_Property bl "Dist (A-B)")
		(#Asmi_Get_Dynamic_Property bl "Dist (C-B)")
		(#Asmi_Get_Dynamic_Property bl "Dist (A-C)")
		); end list
		prLst
	    ); end cons
	); end setq
); end foreach
     (setq lLen(length prLst))
     (while prLst
         (setq rpLst(cons(append(car prLst)
                      (list(- lLen(setq lLen(length (setq prLst
                (vl-remove(car prLst)prLst)))))))rpLst)
          ); end setq
       ); end while
    (setq rpLst(vl-sort rpLst
		'(lambda(a b)(<(car a)(car b)))))
    (princ "\n\n A-B         C-B         A-C         Count")
    (princ "\n ------------------------------------------")
(foreach str rpLst
 (princ(strcat "\n "(rtos(car str)) " "))
 (repeat(- 10(strlen(rtos(car str))))(princ " "))
 (princ(strcat " "(rtos(cadr str)) " "))
 (repeat(- 10(strlen(rtos(cadr str))))(princ " "))
 (princ(strcat " "(rtos(nth 2 str))" "))
 (repeat(- 10(strlen(rtos(nth 2 str))))(princ " "))
 (princ(strcat " "(itoa(last str))))
); end foreach
     (princ "\n ------------------------------------------")
     (textscr)
     ); end progn
   ); end if
 (princ)
); end of c:dycnt

 

Test with your drawing:

 

Command: dycnt


A-B         C-B         A-C         Count
------------------------------------------
4           1           3           1
10          4           6           2
10          5.5         4.5         1
14          8           6           2
14          9.5         4.5         10
20          14          6           1
20          15.5        4.5         14
26          20          6           1
26          21.5        4.5         2
------------------------------------------

 

If you need to fiill attributes I can add it. But today I havn't more free time.

Link to comment
Share on other sites

It because your block has another name "Despiece (1)" (in first drawing was "Despiece (Prueba 03)"). Find list:

 

'("Despiece (Prueba 03)")

 

inside code and add new block names, for example:

 

'("Despiece (Prueba 03)" "Despiece (1)" )

 

 

Visibility state isn't a reason that code don't works.

Link to comment
Share on other sites

Good morning (from Spain)

ASMI, Have you got the option to fill out the attributes?

 

I have a doubt, I've been modifying LIST to more length measures if needed.

Ie;

1. AC, CB

2. AC, CD, DB.

3. AC, CD, DE, EB.

4. ....

5. …

 

So that's what I've changed ...

 

 

(defun c:dycnt(/ dySet prLst rpLst lLen)

 

(vl-load-com)

 

(defun #Asmi_Extract_Dynamic_Blocks(SelSet NameList / bCnt eCnt cBl eBl oSet)

(if(and SelSet NameList)

(progn

(setq bCnt 0

NameList(mapcar 'strcase NameList)

eCnt(sslength SelSet)

oSet(ssadd)

); end setq

(repeat eCnt

(setq cBl(vlax-ename->vla-object

(setq eBl(ssname SelSet bCnt))))

(if

(and

(= "AcDbBlockReference"(vla-get-ObjectName cBl))

(vlax-property-available-p cBl 'EffectiveName)

(member(strcase(vla-get-EffectiveName cBl))NameList)

); end and

(ssadd eBl oSet)

); end if

(setq bCnt(1+ bCnt))

); end repeat

);end progn

); end if

oSet

); end of #Asmi_Extract_Dynamic_Blocks

 

 

(defun #Asmi_Get_Dynamic_Property(Block Property / oVal)

(if(= 'ENAME(type Block))

(setq Block(vlax-ename->vla-object Block))

); end if

(if(= :vlax-true(vla-get-IsDynamicBlock Block))

(foreach p(vlax-safearray->list

(vlax-variant-value

(vla-GetDynamicBlockProperties Block)))

(if(=(strcase Property)(strcase(vla-get-PropertyName p)))

(if(vl-catch-all-error-p

(setq oVal(vl-catch-all-apply

'vla-get-Value(list p))))

nil

(setq oVal(vlax-variant-value oVal))

); end if

); end if

); end foreach

); end if

oVal

); end of #Asmi_Get_Dynamic_Property

 

(defun #Asmi_Set_to_List(Sel_Set VLA / Out)

(setq Out

(vl-remove-if 'listp

(mapcar 'cadr(ssnamex Sel_Set))))

(if VLA

(mapcar 'vlax-ename->vla-object Out)

Out

); end if

); end of #Asmi_Set_to_List

 

 

(if

(and

(setq dySet(ssget "_X" '((0 . "INSERT"))))

(setq dySet

(#Asmi_Extract_Dynamic_Blocks dySet

'("Dynamic Block" "Dynamic Block (1)" "Dynamic Block (2)" "Dynamic Block (3)" "Dynamic Block (4)")))

); end if

(progn

(foreach bl(#Asmi_Set_to_List dySet T)

(setq prLst(cons

(list

(#Asmi_Get_Dynamic_Property bl "Dist (A-B)")

(#Asmi_Get_Dynamic_Property bl "Dist (A-C)")

(#Asmi_Get_Dynamic_Property bl "Dist (C-D)")

(#Asmi_Get_Dynamic_Property bl "Dist (D-E)")

(#Asmi_Get_Dynamic_Property bl "Dist (E-F)")

(#Asmi_Get_Dynamic_Property bl "Dist (F-G)")

(#Asmi_Get_Dynamic_Property bl "Dist (G-H)")

(#Asmi_Get_Dynamic_Property bl "Dist (H-I)")

(#Asmi_Get_Dynamic_Property bl "Dist (C-B)")

(#Asmi_Get_Dynamic_Property bl "Dist (D-B)")

(#Asmi_Get_Dynamic_Property bl "Dist (E-B)")

(#Asmi_Get_Dynamic_Property bl "Dist (F-B)")

(#Asmi_Get_Dynamic_Property bl "Dist (G-B)")

(#Asmi_Get_Dynamic_Property bl "Dist (H-B)")

(#Asmi_Get_Dynamic_Property bl "Dist (I-B)")

); end list

prLst

); end cons

); end setq

); end foreach

(setq lLen(length prLst))

(while prLst

(setq rpLst(cons(append(car prLst)

(list(- lLen(setq lLen(length (setq prLst

(vl-remove(car prLst)prLst)))))))rpLst)

); end setq

); end while

(setq rpLst(vl-sort rpLst

'(lambda(a b)(

(princ "\n\n A-B A-C C-D D-E E-F F-G G-H H-I C-B D-B E-B F-B G-B H-B I-B Count")

(princ "\n -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")

(foreach str rpLst

(princ(strcat "\n "(rtos(car str)) " "))

(repeat(- 10(strlen(rtos(car str))))(princ " "))

(princ(strcat " "(rtos(cadr str)) " "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 2 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 3 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 4 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 5 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 6 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 7 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 8 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 9 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 10 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 11 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 12 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 13 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 14 str))" "))

(repeat(- 10(strlen(rtos(cadr str))))(princ " "))

(princ(strcat " "(rtos(nth 15 str))" "))

(repeat(- 10(strlen(rtos(nth 2 str))))(princ " "))

(princ(strcat " "(itoa(last str))))

); end foreach

(princ "\n ------------------------------------------")

(textscr)

); end progn

); end if

(princ)

); end of c:dycnt

Link to comment
Share on other sites

Greetings.

 

I unfortunately do not understand on Spanish and I wish to ask about attributes. You have two attributes "Distancia Tuberia" and "Tuberia", specify please what information and in what format you wish to see.

Link to comment
Share on other sites

"Distance pipe" is to indicate the total length. Example: 1000mm, 3450mm, ...

"Pipe" is to classify.

Example: 1A, 2B, 1C, 4D, ...

The ranking is the pipes for the execution site.

When the worker has to install these pipes knows which is which mounts, second level.

Example. Pipe type "1A" - Pipe Distance: 1900mm, Quantity: 90 units

 

The dynamic block have 2 functions.

1 for manufacturing pipes for that is divided into AB, AC, CB. AB, AC, CD, DB, ...

2nd Mount pipes:

Pipe "A" is formed by AB, AC, CB. is 5000mm and there are "67" units

 

My English is not good, I hope I have clarified.

 

My idea is to modify the attribute using a List or a table. And the possibility of quick selection of dynamic block through the attribute.

Link to comment
Share on other sites

In general clearly, but at me now it is a lot of work. I will return to it little bit later. I should tell that it little bit more difficult than I represented. You can show blocks with distances CD, DE, EB, etc. and something real drawings (look e-mail at my website if do not wish to publish it at a forum).

 

For me English too not the native language.

Link to comment
Share on other sites

Sorry for my bad English.

ASMI, your help has been great.

I do not need much information in a dynamic block. Only with the possibility of being able to modify the attribute using the "LIST" or similar. And the possibility of selecting a dynamic block through its attribute. Is it possible to create such a "LIST"?

 

Thank you

Link to comment
Share on other sites

Dynamic blocks are an amazing feature, but they can be complicated. This tutorial will teach you many techniques that you can use in your own blocks. The door will do the following:

Future AutoCAD Dynamic Blocks Wish List:

  1. Dynamic Block manipulation from Insert command: This would allow users to Change Visibility states at INSERT. This would also prompt for LINEAR lengths similar to how attributes work at insert. The command line would list all changeable Dynamic block properties for users to manipulate at the time of INSERT.
  2. Nested Visibility states: The Visibility state manager would open up for a lot more potential if the Visibility state manager allowed multiple nested visibility states. A simple example is say you have a 2x4 piece of lumber block "X". And you have it changing sizes through a linear parameter. And changing to a 2x4 block "/" through a visibility state manager. But if there was a variable for a nested Visibility state, you could manipulate the layers, linetypes without having to have separate states for every single type.
  3. Dynamic Block Tool Tip Help strings. It would really help users understand what a Dynamic block does once they select the grip or hoover over it. It would bring up a little help string telling them what the Dynamic block grip does similar help strings like the HYPERLINK tool tip does.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...