• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

insert block and attribute to different quotas

  • Thread starter Thread starter piratabobo
  • Start date Start date

piratabobo

Guest
Hello to all I have a problem that I cannot solve, I create a block with its attribute and insert it in the drawing, the block consists of a circle and attributes, in the insertion of the block I would like to insert the circle in a coordinate and the attribute in another coordinate, I do not know if the thing can be feasible, I hope someone can give me a straight, this is the code I use to create and insert the block:

'create the ethical layer if there is no
for i = 0 to thisdrawing.layers.count - 1
name = thisdrawing.layers.item(i).name
if name = "etichet" then exit for
next i

if name < etichet then
set object = thisdrawing.layers.add("etichet")
end if

lazy = 4 * atn(1)
ang = (pigreco * cdbl(txt_ang.text) / 180
type = "data"

'It inserts block image
items() = split(cbo_blocco.text, ")
cod = (items(0))

'It inserts the block
pnt = thisdrawing.utility.getpoint
x = pnt(0)
y = pnt(1)

'checks the existence of the block in the design
for i = 0 to thisdrawing.blocks.count - 1
name = thisdrawing.blocks.item(i).name
if name = type then exit for
next i

if name <
p1(0) = 0#: p1(1) = 0#: p1(2) = 0#
set oblock = thisdrawing.blocks.add(p1, type)

'creates the block insert highlighting circle
radius = 1.2
set entity = oblock.addcircle(p1, radius)
entity.color = acred

height = 3.76
mode = acattributemonormal
value = "

p2(0) = 3.75: p2(1) = 3.5: p2(2) = 0

tag = "code": prompt = ""
set attrib = oblock.addattribute(height, mode, prompt, p2, tag, value)
attrib.layer = "etichet"
attrib.color = acwhite

mode = acattributemodeinvisible
value = "

tag = "name": prompt = ""
set attrib = oblock.addattribute(height, mode, prompt, p2, tag, value)
attrib.layer = "etichet"
attrib.color = acwhite

mode = acattributemodeinvisible
value = "

tag = "description": prompt = ""
set attrib = oblock.addattribute(height, mode, prompt, p2, tag, value)
attrib.layer = "etichet"
attrib.color = acwhite


p2(0) = x : p2(1) = y : p2(2) = 0
set obkref = thisdrawing.modelspace. insertblock(p2, type, 1, 1, 1, 0)
obkref.layer = "etichet"

call label

p2(0) = x : p2(1) = y : p2(2) = 0
set obkref = thisdrawing.modelspace. insertblock(p2, type, 1, 1, 1, 0)
obkref.layer = "etichet"
end if


pnt = obkref.getattributes

for i = lbound(pnt) to ubound(pnt)
tag = pnt(s).tagstring

select houses tag
houses is = "code"
pnt(i).textstring = lbl_codifica.caption
houses is = "name"
pnt(i).textstring = lbl_nome.caption
houses is = "description"
pnt(i).textstring = lbl_description.caption
end select
next i


pnttot(0) = x: pnttot(1) = y: pnttot(2) = 0
set obkref = thisdrawing.modelspace. insertblock(pnttot, path & "blocchi\" & cod & ".dwg", 1, 1, 1, ang)
 
Sorry, I just wanted to ask the gurus if what I ask is practically not feasible, or if you can do, in case it is feasible, I would be grateful for a straight answer
 
Sorry, I just wanted to ask the gurus if what I ask is practically not feasible, or if you can do, in case it is feasible, I would be grateful for a straight answer
but the "placed" attributes should be those of the block you create or those of the block you insert at the end (set obkref = thisdrawing.modelspace. insertblock(pnttot, path & "blocchi\" & cod & ".dwg", 1, 1, 1, ang) ?
 
First of all, thanks to the answer, the "moved" attributes should be those of the block that I insert at the end, in fact I need to move the attribute when I insert the block.
 
I wanted to add that by moving the attribute the insertion point deo block must not change.
 
dim att as variant
dim x2 (0 to 2) as double

att = obkref.getattributes' returns the array of attributes

x1 = att(s).textalignmentpoint 'where i is the number of the element in the array from 0 up to number attributes

x2(0) = x1(0) 'x2(0)+y 'coordinated x of the absolute or relative attribute insertion point
x2(1) = x1(1) 'x2(1) +y 'coordinated y of the absolute or relative attribute insertion point
x2(2) = x1(2) 'x2(2) +y 'coordinated z of the absolute or relative attribute insertion point

att(i).textalignmentpoint = x2

this is the method then I do not know if all attributes or only in part, to check how many attributes use the lbound(att) to ubound(att)

if the coordinate is known you can emptie to read x1 and set x2 directly to the desiaderate coordinates. . .
 
I tried to use the code above and I think I'm wrong but I don't know what because inserting attributes doesn't change, I changed the code like this:

pnt = obkref.getattributes

dim x2(0 to 2) as double

== sync, corrected by elderman ==
x2(1) = 0
x2(2) = 0

for i = lbound(pnt) to ubound(pnt)
tag = pnt(s).tagstring

select houses tag
houses is = "code"
pnt(i).textstring = lbl_codifica.caption
houses is = "name"
pnt(i).textstring = lbl_nome.caption
houses is = "description"
pnt(i).textstring = lbl_description.caption
end select

pnt(i).textalignmentpoint = x2

next i


pnttot(0) = x: pnttot(1) = y: pnttot(2) = 0
set obkref = thisdrawing.modelspace. insertblock(pnttot, path & "blocchi\" & cod & ".dwg", 1, 1, 1, ang)

inserting the block, the location of the attributes does not vary even if the value of the x2(0) the attribute is always inserted in the same position
 
I tried to use the code above and I think I'm wrong but I don't know what because inserting attributes doesn't change, I changed the code like this:

pnt = obkref.getattributes

dim x2(0 to 2) as double

== sync, corrected by elderman ==
x2(1) = 0
x2(2) = 0

for i = lbound(pnt) to ubound(pnt)
tag = pnt(s).tagstring

select houses tag
houses is = "code"
pnt(i).textstring = lbl_codifica.caption
houses is = "name"
pnt(i).textstring = lbl_nome.caption
houses is = "description"
pnt(i).textstring = lbl_description.caption
end select

pnt(i).textalignmentpoint = x2

next i


pnttot(0) = x: pnttot(1) = y: pnttot(2) = 0
set obkref = thisdrawing.modelspace. insertblock(pnttot, path & "blocchi\" & cod & ".dwg", 1, 1, 1, ang)

inserting the block, the location of the attributes does not vary even if the value of the x2(0) the attribute is always inserted in the same position
doesn't work because before you move the attribute you have to insert the block

pnt = obkref.getattributes

cannot work because et obkref = thisdrawing.modelspace. insertblock(pnttot, path & "blocchi\" & cod & ".dwg", 1, 1, 1, ang)

insert it after... so you can't take the values.

what you want to do is a "local" change of the only inserted block, so it is like taking the grip of the attribute and moving it. You have to do it later.
 
thanks shape of the tips I solved using instead of:

pnt(i).textalignmentpoint = x2

this:

pnt(i). insertionpoint = x2

and works perfectly
 
thanks shape of the tips I solved using instead of:

pnt(i).textalignmentpoint = x2

this:

pnt(i). insertionpoint = x2

and works perfectly
He thinks I did the opposite, I had tried with insertionpoint on an inserted block and did not move the attribute with textalignmentpoint yes.

probably we have done two things halfway opposite to get the same result !!!
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top