• このフォーラムは、www.cad3d.it/forum1 - イタリアのデザインコミュニティの機械翻訳です。いくつかの用語は正しく翻訳されていません。

座標ブロック

  • Thread starter Thread starter OneWay
  • Start date Start date

OneWay

Guest
salve a tutti, sono nuovo nel forum e ho un problema:

sto realizzando un semplice programmino in autoit che si interfaccia con autocad, il problema è che se interrogo autocad sulle coordinate di un blocco, 'insertionpoint' mi ritorna una variabile vuota, so che è una variabile double che contiene x y z ma in autoit le matrici vengono gestite con [] e non () non so se è questo il problema, getentity mi risponde nella stessa maniera, vuota.

esiste il modo di estrapolare x y z in una variabile non double.

ringrazio e mi scuso per la forma forse un poco affrettata, ma l'ora e tarda e connetto sempre meno, qualsiasi suggerimento e ben accetto.

saluti:p
 
salve a tutti, sono nuovo nel forum e ho un problema:

sto realizzando un semplice programmino in autoit che si interfaccia con autocad, il problema è che se interrogo autocad sulle coordinate di un blocco, 'insertionpoint' mi ritorna una variabile vuota, so che è una variabile double che contiene x y z ma in autoit le matrici vengono gestite con [] e non () non so se è questo il problema, getentity mi risponde nella stessa maniera, vuota.

esiste il modo di estrapolare x y z in una variabile non double.

ringrazio e mi scuso per la forma forse un poco affrettata, ma l'ora e tarda e connetto sempre meno, qualsiasi suggerimento e ben accetto.

saluti:p

insertionpoint

variant (three-element array of doubles); read-write
a 3d wcs coordinate representing the insertion point.

in vba la variabile che ti ritorna non è un double ma un variant array 3 dimensioni, insertionpoint(0)=x insertionpoint(1)=y insertionpoint(2)=z

il double lo utilizzi solo se devi comporre la matrice

buon lavoro
 
Last edited:
ti ringrazio, infatti in vba non ho problemi a gestirlo ma in autoit non è la stessa cosa.

comunque, non esiste il modo di gestire l'array 1-2-3 come una stringa unica, magari con un comando interno ad autocad che concatena l'array, o anche un modo di estrarre la singola variabile x, y, z come per xscalefactor, yscalefactor ecc.

se conosci e usi autoit posso inserire il codice per comprendere meglio.

ho provato ad usare anche getentity ma anche in questo caso mi restituisce la variabile insertpoint che 'sembra vuota', sembra, perchè in realtà non riesco a gestirla come array in autiit.

dimmi tu, visto che in tre forum in cui ho fatto questa domanda sei l'unico che si sia azzardato a rispondermi.
 
in che modo ti nterfacci con autocad ?

scrivimi due righe per capire come funziona e vediamo se ne usciamo
 
ti passo uno script in autoit il linguaggio che vorrei utilizzare.

code:
$acadapp = objget("","autocad.application")
dim $sset, $ent
$acaddoc = $acadapp.activedocument
winactivate ($acadapp.caption,$acaddoc.name)
$sset = $acaddoc.activeselectionset
$sset.selectonscreen
for $ent in $sset
if $ent.entityname = "acdbblockreference" then
msgbox(0,"specifiche blocco","scalex: " & $ent.xscalefactor & @cr & _
"scaley: " & $ent.yscalefactor & @cr & _
"scalez: " & $ent.zscalefactor & @cr & _
"unita mis: " & $ent.insunits & @cr & _
"nome: " & $ent.name & @cr & _
"idobj: " & $ent.objectid & @cr & _
"nomeeff: " & $ent.effectivename & @cr & _
"insertp: " & $ent.insertionpoint & @cr & _
"layer: " & $ent.layer & @cr & _
"material: " & $ent.material & @cr & _
"insertp: " & $ent.objectname)
else
msgbox (0,"","hai mancato il blocco!" & @cr & "riprova sarai più fortunato.")
endif
next

prima di tutto occorre aprire un autocad ed inserire un blocco, dopodichè all'esecuzione dello script si seleziona il blocco e ti apparirà un box con le specifiche.

$ent.insertionpoint come vedrai sarà vuoto, in autoit le matrici si gestiscono con le [] e non con (), ma visualizzando $ent.insertionpoint[0], 1, 2 darà un errore.

inizio a pensare che probabilmente non è possibile reperire quella info, anche se tutte le altre vengono visualizzate correttamente.

ti ringrazio in anticipo :)
 
allora premetto che non conosco autoit ma ho scaricato il prog e non sembra molto diverso dal vb...

prova a vedere con questo


dim $myarray[10][20] ;element 0,0 to 9,19
$rows = ubound($myarray)
$cols = ubound($myarray, 2)
$dims = ubound($myarray, 0)

msgbox(0, "the " & $dims & "-dimensional array has", _
$rows & " rows, " & $cols & " columns")

;display $myarray's contents
$output = ""
for $r = 0 to ubound($myarray,1) - 1
$output = $output & @lf
for $c = 0 to ubound($myarray,2) - 1
$output = $output & $myarray[$r][$c] & " "
next
next
msgbox(4096,"array contents", $output)


se gestisci insertionpoint come un array e provi a ripescarlo forse funziona
 
Last edited:
dunca, ho provato a mescolare le carte col codi che mi hai inviato ma non ho generato nossun dato, aimè.

code:
dim $myarray[10][20] ;element 0,0 to 9,19
$rows = ubound($myarray)
$cols = ubound($myarray, 2)
$dims = ubound($myarray, 0)

msgbox(0, "the " & $dims & "-dimensional array has", $rows & " rows, " & $cols & " columns")

;display $myarray's contents
$output = ""
for $r = 0 to ubound($myarray,1) - 1
$output = $output & @lf
for $c = 0 to ubound($myarray,2) - 1
$output = $output & $myarray[$r][$c] & " "
next
next
msgbox(4096,"array contents", $output)



$acadapp = objget("","autocad.application")
dim $sset, $ent, $ena

$acaddoc = $acadapp.activedocument
winactivate ($acadapp.caption,$acaddoc.name)
$sset = $acaddoc.activeselectionset
$sset.selectonscreen

for $ent in $sset
if $ent.entityname = "acdbblockreference" then
msgbox(0,"specifiche blocco","scalex: " & $ent.xscalefactor & @cr & _
"scaley: " & $ent.yscalefactor & @cr & _
"scalez: " & $ent.zscalefactor & @cr & _
"unita mis: " & $ent.insunits & @cr & _
"nome: " & $ent.name & @cr & _
"idobj: " & $ent.objectid & @cr & _
"nomeeff: " & $ent.effectivename & @cr & _
"insertp: " & $ent.insertionpoint & @cr & _
"layer: " & $ent.layer & @cr & _
"material: " & $ent.material & @cr & _
"insertp: " & $ent.objectname)
else
msgbox (0,"","hai mancato il blocco!" & @cr & "riprova sarai più fortunato.")
endif
next



$myarray = $sset
$output = ""
for $r = 0 to ubound($myarray,1) - 1
$output &= @lf
for $c = 0 to ubound($myarray,2) - 1
$output &= $myarray[$r][$c] & " "
next
next
msgbox(4096,"array contents", $output)

ho provato anche $myarray = $ent.insertionpoint al posto di $myarray = $sset ma il risultato non cambia, l'array risulta vuota.

altra cosa, si puo elencare i nomi delle proprietà dell'oggetto, prelevandole dall'oggetto stesso, es:

xscalefactor
insunits
layer

in modo da sapere prima il nome della proprietà cosa si può interrogare.

ti ringrazio comunque, anche se mi sà che non ne caveremo un ragno dal buco.
 
ehh io qui mollo la presa perchè mi sto pure innervosendo....

fammi sapere se risolvi...

buona fortuna....

un domanda stupida.... perchè autoit e non vb ? o ancor meglio vba che puoi interlacciarlo anche con office eventualmente ?
 
scusa se ti ho fatto innervosire non era mia intenzione.

uso vba da qualche anno e volevo qualcosa di più sfizioso, ho iniziato a masticare vbscript, molto interessante ma mi mancavano le interfacce, gui se non erro, e sono approdato ad autoit che tra l'altro mi permette di generare degli eseguibili che non hanno bisogno di ocx e menate varie.

ultima cosa, per il discorso di estrarre i nomi delle proprietà da un oggetto sai darmi una dritta?

un saluto.
 
forse così ce la fai....

comando: (entget(car(entsel)))

selezionare oggetto: ((-1 . <nome entità: 7eda9a80>) (0 . "insert") (330 .
<nome entità: 7efe3cf8>) (5 . "26480") (100 . "acdbentity") (67 . 0) (410 .
"model") (8 . "0") (100 . "acdbblockreference") (66 . 1) (2 . "mar_pez") (10
55048.5 1758.52 0.0) (41 . 15.0) (42 . 15.0) (43 . 15.0) (50 . 0.0) (70 . 0)
(71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

questi sono i codici dxf degli oggetti. come vedi al codice 10 corrisponde il punto di inserimento del blocco...

entity group codes by number
group code description

-5


app: persistent reactor chain

-4


app: conditional operator (used only with ssget)

-3


app: extended data (xdata) sentinel (fixed)

-2


app: entity name reference (fixed)

-1


app: entity name. this changes each time a drawing is opened. it is never saved. (fixed)

0


text string indicating the entity type (fixed)

1


primary text value for an entity

2


name (attribute tag, block name, and so on)

3-4


other textual or name values

5


entity handle. text string of up to 16 hexadecimal digits (fixed)

6


linetype name (fixed)

7


text style name (fixed)

8


layer name (fixed)

9


dxf: variable name identifier (used only in header section of the dxf file).

10


primary point. this is the start point of a line or text entity, center of a circle, and so on.
dxf: x value of the primary point (followed by y and z value codes 20 and 30)
app: 3d point (list of three reals)

11-18


other points.
dxf: x value of other points (followed by y value codes 21-28 and z value codes 31-38)
app: 3d point (list of three reals)

20, 30


dxf: y and z values of the primary point

21-28, 31-37


dxf: y and z values of other points

38


dxf: entity's elevation if nonzero.

39


entity's thickness if nonzero (fixed)

40-48


floating-point values (text height, scale factors, and so on)

48


linetype scale. floating-point scalar value. default value is defined for all entity types.

49


repeated floating-point value. multiple 49 groups may appear in one entity for variable-length tables (such as the dash lengths in the ltype table). a 7x group always appears before the first 49 group to specify the table length.

50-58


angles (output in degrees to dxf files and radians through autolisp and arx applications).

60


entity visibility. integer value. absence or 0 indicates visibility; 1 indicates invisibility.

62


color number (fixed)

66


"entities follow" flag (fixed)

67


space--that is, model or paper space (fixed)

68


app: identifies whether viewport is on but fully off screen; is not active or is off.

69


app: viewport identification number.

70-78


integer values, such as repeat counts, flag bits, or modes

90-99


32-bit integer values

100


subclass data marker (with derived class name as a string). required for all objects and entity classes that are derived from another concrete class to segregate data defined by different classes in the inheritance chain for the same object.
this is in addition to the requirement for dxf names for each distinct concrete class derived from arx (see "subclass markers").

102


control string, followed by "{<arbitrary name>" or "}". similar to the xdata 1002 group code, except that when the string begins with "{", it can be followed by an arbitrary string whose interpretation is up to the application. the only other allowable control string is "}" as a group terminator. as noted before, autocad does not interpret these strings except during drawing audit operations; they are for application use.

105


dimvar symbol table entry object handle

210


extrusion direction (fixed).
dxf: x value of extrusion direction
app: 3d extrusion direction vector

220, 230


dxf: y and z values of the extrusion direction

280-289


8-bit integer values

300-309


arbitrary text strings

310-319


arbitrary binary chunks with same representation and limits as 1004 group codes: hexadecimal strings of up to 254 characters represent data chunks of up to 127 bytes.

320-329


arbitrary object handles. handle values that are taken "as is." they are not translated during insert and xref operations.

330-339


soft-pointer handle. arbitrary soft pointers to other objects within same dxf file or drawing. translated during insert and xref operations.

340-349


hard-pointer handle. arbitrary hard pointers to other objects within same dxf file or drawing. translated during insert and xref operations.

350-359


soft-owner handle. arbitrary soft ownership links to other objects within same dxf file or drawing. translated during insert and xref operations.

360-369


hard-owner handle. arbitrary hard ownership links to other objects within same dxf file or drawing. translated during insert and xref operations.

999


dxf: the 999 group code indicates that the line following it is a comment string. dxfout does not include such groups in a dxf output file, but dxfin honors them and ignores the comments. you can use the 999 group to include comments in a dxf file that you've edited.

1000


ascii string (up to 255 bytes long) in extended data.

1001


registered application name (ascii string up to 31 bytes long) for extended data.

1002


extended data control string ("{"or "}").

1003


extended data layer name.

1004


chunk of bytes (up to 127 bytes long) in extended data.

1005


entity handle in extended data. text string of up to 16 hexadecimal digits

1010


a point in extended data
dxf: x value (followed by 1020 and 1030 groups)
app: 3d point

1020, 1030


dxf: y and z values of a point

1011


a 3d world space position in extended data
dxf: x value (followed by 1021 and 1031 groups)
app: 3d point

1021, 1031


dxf: y and z values of a world space position

1012


a 3d world space displacement in extended data
dxf: x value (followed by 1022 and 1032 groups)
app: 3d vector

1022, 1032


dxf: y and z values of a world space displacement

1013


a 3d world space direction in extended data.
dxf: x value (followed by 1022 and 1032 groups)
app: 3d vector

1023, 1033


dxf: y and z values of a world space direction

1040


extended data floating-point value.

1041


extended data distance value.

1042


extended data scale factor.

1070


extended data 16-bit signed integer.

1071


extended data 32-bit signed long.
 
uuhh che botta, per fortuna che ti eri innervosito :)

mi piacerebbe chiederti dove cavolo hai trovato quel comando, micidiale, hai riaperto la voglia di riprendere un altro progetto che avevo in mente, cmq.

hai fatto 30, ti prego fai 31...

(entget(car(entsel))) > d:\xxx.txt dxf ccp cococo.
dimmi che si può fare e magari anche come, con non ci starebbe male.

reindirizzare l'output in un file o se esiste del cod. vba che preleva i dati che appaiono a video

troppo... magari prima un p'o' di camomilla cosi ti rilassi. ;)
 
ora la butto li.. ma perche non utilizzi autoit per lanciare una macro vba in autocad che crea il file e poi utilizzi quello per fare il resto ?
 
e si, hai ragione, mi stavo adagiando troppo, però se riuscivo a strapparti anche quest'ultima info ero 'quasi' a posto.

francamente stavo pensando anche io, più che a vba a vbs, anche se manca di stile:

autoit che genera un vbscript che a sua volta genera un txt che viene prelevato da autoit.

ok ci provo, dovrei anche riuscirci, spero.

per il momento ti saluto e ti ringrazio, spero di risentirti per darti la buona notizia.

ciao e grazie.
 
(defun c:esportx ()
(setq nomefile "c:\creafile.txt")
(setq fr (open nomefile "a"))
(setq lista (entget (car (entsel))))
(write-line (vl-princ-to-string lista) fr)
(close fr)
)

grazie a rrpor66 ho trovato il modo di salvare il risultato della funzione (entget (car (entsel))) nel file come volevi tu.
 
Last edited:
ciao, ero impegnato a capire come funziona l'autolisp e alla fine avevo sfornato questo:

(entget(car(entsel)))
(setq x (cdr (assoc 2 entlist)))
(if (= x "sk")
(
(setq f(open "d:\\xgiga.txt" "w"))
(write-line (rtos(cadr(assoc 10 entlist)) 2) f)
(write-line (rtos(caddr(assoc 10 entlist)) 2) f)
(close f)
)
"no."
)

sembrava quasi funzionare, poi ho chiuso e riaperto autocad e come per magia non riesco più ad estrarre il valore della lista 2 (assoc 2 entlist)) che è sempre (2 . sk)
che è poi il nome del blocco.
sono quasi in panico, un codice se non lo modifichi dovrebbe reagire sempre nello stesso modo o no?

bon, una bella tisana per me e con calma provo il tuo codice.

secondo te cosa non va' nel mio codice.
 
oh non so cosa rispondere carico lsp eseguo comando esportx seleziono l'oggetto e lui mi risponde nil! credo voglia dire nullo.

uso autocad 2008 nel caso servisse.

continuerò a provare, cavolo deve funzionare.
 
autolisp non è il mio pane quotidiano... me la cavo meglio con vba...rrpor66 ne sa mollllto... mada a lui un msg in pvt e quando ha tempo ti risponde

ma poi scusa

se il codice che ti ho mandato io ti salva correttamente tutta la lista

pioi sai che

(10 55048.5 1758.52 0.0) sono le coordinate

usa autoit per manipolare la stringa e trasformi i valori in x y z
 
Last edited:
scusate la mia assenza non vi ho dimenticati, (problemi a casa, figlio con otite, precedenza assoluta).

dunque, ho studiato, ho mischiato mescolato, ho aggiunto due cubetti di ghiaccio ed è risultato questo:

(setq lista (entget (car (entsel))))
(setq xx (rtos(cadr(assoc 10 lista)) 2))
(setq yy (rtos(caddr(assoc 10 lista)) 2))
(setq sk (cdr(assoc 2 lista)))
(setq nomefile "d:/xxxx.txt")
(setq fr (open nomefile "w"))
(if (= sk "sk")
((write-line yy fr)
(write-line xx fr))
"no")
(close fr)

il risultato è un file con due righe ti testo x e y, mi manca solo una cosa, nel caso non riesca ad selezionare nulla mi genera un errore:

selezionare oggetto: ; errore: tipo di argomento errato: lentityp nil

devo capire come intercettarlo, lo studio è ancora lungo.

in ogni caso devo ringraziarti per l'aiuto e il tempo che mi hai concesso.

se e quando ci riuscirò lo aggiungerò a questo post, potrebbe servire a qualcun altro.

terrò presente rrport66, grazie
bye
 

Forum statistics

Threads
46,674
Messages
380,976
Members
2
Latest member
loop80
このフォーラムは、www.cad3d.it/forum1 - イタリアのデザインコミュニティの機械翻訳です。いくつかの用語は正しく翻訳されていません。

Members online

No members online now.
Back
Top