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

reading of all texts within a polyline

  • Thread starter Thread starter Qoricino
  • Start date Start date

Qoricino

Guest
salve a tutti. :biggrin:
devo riuscire a leggere tutti i testi presenti in una polilinea chiusa che formo tramite la funzione "mantieni contorni" della "creazione retino".
premetto che sto lavorando con autocad 2007 e vba.
all'interno della polilinea, creata sul layer "aree" si trovano 2 testi: primo su layer "areetesto" ed il secondo su layer "appartamenti".
il tutto mi serve per estrapolare in excel da immensi disegni tutte le aree ed i perimetri dei singoli locali.
il codice che al momento ho testato è il seguente. funziona, ma determinate aree me le salta, e non riesco a capire perchè dato che i testi inseriti sono tutti copie degli altri, ed ho verificato che fossero tutti mtext.:frown::frown:
qualcuno può aiutarmi??
grazie!!!!

public sub areetoexcelapp()
dim scala as integer
dim str as string
str = "importante: tutte le aree ed i testi delle stanze devono essere su layer " & chr(34) & "aree" & chr(34) & vbcrlf
str = str & "la numerazione degli alloggi deve essere posizionato sul layer " & chr(34) & "appartamenti" & chr(34) & vbcrlf & vbcrlf
str = str & "1 m corrisponde a: "
scala = inputbox(str, "scala disegno", 100)
dim oent as acadentity
dim punti3d as variant
dim sset as acadselectionset
dim sset1 as acadselectionset
dim element as acadmtext
dim element1 as acadmtext
dim elmod as acadmtext
dim filtertype(0) as integer
dim filterdata(0) as variant
dim coord as variant
dim appart, msg as string
dim area, cornice as double

'creazione file excel
dim excel as object
dim excelsheet as object
on error resume next
set excel = getobject(, "excel.application")
if err <> 0 then
err.clear
set excel = createobject("excel.application")
if err <> 0 then
msgbox "could not load excel.", vbexclamation
end
end if
end if
on error resume next
excel.visible = true
excel.workbooks.add
excel.sheets("foglio1").select
set excelsheet = excel.activeworkbook.sheets("foglio1")
dim cc as integer
cc = 1
excelsheet.cells(cc, 5).value = "unità"
excelsheet.cells(cc, 1).value = "n°"
excelsheet.cells(cc, 2).value = "locale"
excelsheet.cells(cc, 3).value = "area"
excelsheet.cells(cc, 4).value = "cornice"
'excelsheet.cells(cc, 5).value = "watt"
cc = cc + 1

'tutte le entità prensenti nel modello
for each oent in thisdrawing.modelspace
'se è sul layer "aree"
if typeof oent is acadlwpolyline then
if oent.layer = "aree" then
msg = ""
appart = ""
set elmod = nothing
'se l'entità è una polilinea
'if typeof oent is acadlwpolyline then
oent.highlight true
'inizio ------
on error resume next
' delete the selection set if it exists
if not isnull(thisdrawing.selectionsets.item("element")) then
set sset = thisdrawing.selectionsets.item("element")
sset.delete
end if

set sset = thisdrawing.selectionsets.add("element")

'sset.additems (oent)
'sset.selectonscreen

'coord = sset.item(0).coordinates
coord = oent.coordinates

x = ((ubound(coord) - 1) / 2) + ubound(coord)

redim punti3d(0 to x + 1) as double
u = 0
for i = 0 to ubound(coord) step 2
punti3d(u) = coord(i)
punti3d(u + 1) = coord(i + 1)
u = u + 2
punti3d(u) = 0
u = u + 1
next i

' delete the selection set if it exists
if not isnull(thisdrawing.selectionsets.item("element1")) then
set sset1 = thisdrawing.selectionsets.item("element1")
sset1.delete
end if

set sset1 = thisdrawing.selectionsets.add("element1")

filtertype(0) = 0
filterdata(0) = "mtext"


sset1.selectbypolygon acselectionsetwindowpolygon, punti3d, filtertype, filterdata
'msgbox ("elementi selezionati:" & sset1.count)
z = 1

thisdrawing.regen acallviewports

for each element1 in sset1
if element1.layer = "appartamenti" then
appart = element1.textstring
set elmod = nothing
set elmod = element1
else
if element1.layer = "areetesto" then
if isnumeric(vba.left(element1.textstring, 1)) = false then
element1.highlight true
if vba.left(element1.textstring, 1) = "{" then
msg = puliscitesto(element1.textstring)
set elmod = element1
else
msg = element1.textstring
set elmod = element1
end if
'msgbox msg
'msgbox ("oggetto" & z & ":" & element1.name & vblf & "punto inserimento" & vblf & "x: " & element1.insertionpoint(0) & vblf & "y: " & element1.insertionpoint(1) & vblf & "rotazione: " & (element1.rotation) / pigreco * 180)
z = z + 1
element1.highlight false
else
msg = ""
end if
end if
end if
next
if msg <> "" then
if oent.area > 0 and oent.length > 0 then
excelsheet.cells(cc, 1).value = cc - 1
excelsheet.cells(cc, 2).value = msg
excelsheet.cells(cc, 3).value = arrotonda_eccesso(oent.area / scala ^ 2, 1)
excelsheet.cells(cc, 4).value = arrotonda_eccesso((oent.length - 1) / scala, 0)
excelsheet.cells(cc, 5).value = appart
'aggiungere numero stanza con pallino
elmod.textstring = cc - 1 & " - " & elmod.textstring
cc = cc + 1
end if
end if
'fine -----
oent.highlight false
end if
end if
next oent
end sub
 
If I didn't get a response about vba, there would be an alternative approach.

instead of extrapolating texts from the inside of poly, you could export the contours of the retini in shape, together with their geometric properties type area, perimeter, and the unique id called "handle".

to do this, you should get the 30-day autocad map trial from the autodesk site, and eventually one of the 3 shape-set files will be natively read by excel.

shape then has other advantages: Maybe if you zip and attach here the layer of contours (without texts) you will discover a new world.

:
 
If I didn't get a response about vba, there would be an alternative approach.

instead of extrapolating texts from the inside of poly, you could export the contours of the retini in shape, together with their geometric properties type area, perimeter, and the unique id called "handle".

to do this, you should get the 30-day autocad map trial from the autodesk site, and eventually one of the 3 shape-set files will be natively read by excel.

shape then has other advantages: Maybe if you zip and attach here the layer of contours (without texts) you will discover a new world.

:
the problem is that I have to have the name of the room (living room, room, bathroom,...) not the number of polylinea. the second number is the numbering of the accommodation. I need to separate the various data.
Can someone tell me how I can do to see if an object is inside a polyline? :confused::confused
I wanted to pass the program all the polylines, and for each to see if the text is on the inside.....certainly it will be a lentiiiiissiiima operation, but if you give me the certainty to extrapolate all the data, little bad!:rolleyes:
Thank you!
 
acad holders 2008 or higherPlease see if the _dataextraction command can help you: If yes, it's time to update autocad, heart.

on the upgrade to 2011, you will get a generous discount in cad3d writing quality, but only if you turn to the forum var (tristan, start thinking about my commission. . . )
(cut)
 
Last edited by a moderator:
the problem is that I have to have the name of the room (living room, room, bathroom,...) not the number of polylinea. the second number is the numbering of the accommodation. I need to separate the various data.
Can someone tell me how I can do to see if an object is inside a polyline? :confused::confused
I wanted to pass the program all the polylines, and for each to see if the text is on the inside.....certainly it will be a lentiiiiissiiima operation, but if you give me the certainty to extrapolate all the data, little bad!:rolleyes:
Thank you!
acad holders 2008 or higherPlease see if the _dataextraction command can help you: If yes, it's time to update autocad, heart.
with the _dataextraction command directly it is not possible to see if an object is located within a closed polylinea date.
However, you can use it to get there, provided you have every closed polyline (with its text) on a different layer. but it seems to me to understand that it is not possible to see the "immensity" of the drawings.
of course always with that command it is possible to know the area and perimeter of each closed polylinea (if this can serve to qoricino).
 
pr,
returning a moment to the way shape method, that you know, there are "exporters" for normal autocad?

I looked for them on the net, but in vain, thank you.

:
 
with the _dataextraction command directly it is not possible to see if an object is located within a closed polylinea date.
However, you can use it to get there, provided you have every closed polyline (with its text) on a different layer. but it seems to me to understand that it is not possible to see the "immensity" of the drawings.
of course always with that command it is possible to know the area and perimeter of each closed polylinea (if this can serve to qoricino).
I thank everyone for the answers. :finger:
exporting polyline data is not a problem, simply done with the .length and .area command
the update to the 2011 version I would say that it is definitely something not feasible, since it is not me to pay and since we should update all the pcs....so I would say that it is clearly out of budget!:frown:
Is it not that someone looking at the code that I "assembled" noticed some mistakes? . ..because export does it properly, only some area jumps, but I don't understand why! :confused::confused
 
pr,
returning a moment to the way shape method, that you know, there are "exporters" for normal autocad?

I looked for them on the net, but in vain, thank you.

:
which export in shape with relative dataset? so much to "transform" it in a gis?
 
the problem is that I have to have the name of the room (living room, room, bathroom,...) not the number of polylinea. the second number is the numbering of the accommodation. I need to separate the various data.
Can someone tell me how I can do to see if an object is inside a polyline? :confused::confused
I wanted to pass the program all the polylines, and for each to see if the text is on the inside.....certainly it will be a lentiiiiissiiima operation, but if you give me the certainty to extrapolate all the data, little bad!:rolleyes:
Thank you!
In my opinion the problem solves it by zooming in the area described by the polyline before creating the selection group.

bye
 
which export in shape with relative dataset? so much to "transform" it in a gis?
no, more simply a tool that exposes carriers with hooked text form geometric attributes without any database connection.

in other words: a shape without .prj of geolocation, concept that normal autocad cannot understand.

:
 
In my opinion the problem solves it by zooming in the area described by the polyline before creating the selection group.

bye
I tried to zoom in on the polyline, regenerating the design, however some areas continue to jump.:frown:
Is there any way of turning a closed polyliena into a region via vba?
 

Forum statistics

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

Members online

No members online now.
Back
Top