Jump to content

Linking Table to Block Attribute


fabriciorby

Recommended Posts

Hello guys :)

This one is huge (I guess)

I have a drawing, in this drawing I want to create a table with 2 columns and 3 rows.

In this drawing I have two blocks too, for each block I have one attribute.

About my blocks:

- Block 1: Attribute 1

- Block 2: Attribute 2

About the table:

- Rows

- First one: Title

- Second one: Header

- Third one: Data (Attributes)

- Colunms

- First one: About Block 1

- Second one: About Block 2

Here is a Screenshot: http://puu.sh/imk9J/fc7b6f8440.png

 

Now, what I need to do is to link them to each other.

Whenever someone change those attributes, I need the data from the table to change too.

Whenever someone change the data from the table, I need the attributes from the blocks to be changed too.

(I would like to try it using reactors)

 

But it's not that simple, to implement this, I need a command to add rows to the table and a command to erase rows from the table.

Whenever someone adds a row and its data, I need to add Block 1 and Block 2 with the data in their attributes.

Whenever someone erase a row, I need the blocks linked to that row to be erased too.

 

Any hints about the reactors? I really don't know how to start it. :(

 

The following code creates the table and the blocks:

(defun c:testing ()
(setq app (vlax-get-acad-object))
(setq doc (vla-get-activeDocument app))
(setq spc (vla-get-block (vla-get-activelayout doc)))
(setq tabela
(if (setq pt (getpoint "\nPick a point to create the table."))
	(vla-addTable spc
		(vlax-3d-point pt) ;
		3 ;
		2 ;
		0.2 ;
		1 ;
	)
)
)
(vla-put-regenerateTableSuppressed tabela :vlax-true)
(vla-setText tabela 0 0 "Title")
(vla-setText tabela 1 0 "Block 1")
(vla-setText tabela 1 1 "Block 2")
(vla-setCellAlignment tabela 2 0 acMiddleCenter)
(vla-setCellAlignment tabela 2 1 acMiddleCenter)
(vla-put-regenerateTableSuppressed tabela :vlax-false)
(block1)
(block2)
)

(defun block1()
(setq block1 
	(vla-add
		(vla-get-blocks doc)
		(vlax-3d-point '(0 0 0))
		"Block 1"
	)
)
(setq attribute1
	(vla-addattribute block1
		0.18 ;(/ (getvar 'dimscale) 10.0) ;altura
		8
		"Attribute 1"
		(vlax-3d-point '(0 0 0))
		"Attribute1"
		"0"
	)
)
(vla-put-alignment attribute1 acAlignmentMiddleCenter)
(vla-addline block1
	(vlax-3d-point '(-1 -1 0))
	(vlax-3d-point '(1 -1 0))
)
(vla-addline block1
	(vlax-3d-point '(1 -1 0))
	(vlax-3d-point '(1 1 0))
)
(vla-addline block1
	(vlax-3d-point '(1 1 0))
	(vlax-3d-point '(-1 1 0))
)
(vla-addline block1
	(vlax-3d-point '(-1 1 0))
	(vlax-3d-point '(-1 -1 0))
)
)

(defun block2()
(setq block2 
	(vla-add
		(vla-get-blocks doc)
		(vlax-3d-point '(0 0 0))
		"Block 2"
	)
)
(setq attribute2
	(vla-addattribute block2
		0.18 ;
		8
		"Attribute 2"
		(vlax-3d-point '(0 0 0))
		"Attribute2"
		"0"
	)
)
(vla-put-alignment attribute2 acAlignmentMiddleCenter)
(vla-addcircle block2
	(vlax-3d-point '(0 0 0))
	1
)
)

 

Edit: To insert the blocks I'm using Unitless as unit

Edited by fabriciorby
Unitless
Link to comment
Share on other sites

sorry but learning reactors and tables are still on my wish list (i have a waiting list for my one and only remaining brain cell...) I'll get there but not any time soon i'm afraid :-(

 

 

rlx

Link to comment
Share on other sites

can you link a table in 2011?

 

I don't know... :(

Maybe I should make a column for the entity names and use reactors to check them everytime I change something, but the reactor part is the problem, how can I call them whenever someone changes the attributes?

Link to comment
Share on other sites

sorry but learning reactors and tables are still on my wish list (i have a waiting list for my one and only remaining brain cell...) I'll get there but not any time soon i'm afraid :-(

 

 

rlx

No problem, haha. Reactors are very confusing, I'm really trying to learn it :(

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...