![]() |
|
|
||||||||
| Site Links |
| Consulting |
| Knowledge Base |
| Training |
| Forum |
| Articles |
| Resources |
| Products |
| Cool Tools |
| Contact |
| About Us |
| Go to Page... |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
|
Solved: Read field in AUTOCAD block attribute
Hi all,
I have a block-reference with attributereferences. One of these references is a calculated field that gives the area of a polyline. This is its calculation expression: %<\AcObjProp Object(%<\_ObjId 2129748024>%).Area \f "%lu2">% where 2129748024 is the ID of the linked polyline. I'd like to get the expression above in order to extract the object id number (2129748024). My aim is to get the id number and use it to insert a new attribute into the block that will have a calculated field corresponding to the length of the same polyline. Thanks in advance. |
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#2 |
|
|
Hi ALe, I posted solution on swamp as well
Here is a quick and dirty code VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#3 |
|
|
Great Fixo, to tell you the truth I hoped you were around!
I'll give a try tonight and let you know! Thank you |
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#4 | |||||||||||||||||||||||
|
|
Sorry I kinda sick a bit and see the forum not too often Hope this will be working on your end, just change an attribute tag (I used 'LENGTH' i.e.) etc... See you Oleg |
|||||||||||||||||||||||
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#5 |
|
|
I hope nothing serious!
I was curious so I started to run the code, I'm having troubles with formatting. I'm supposed to run it via VBA? It seems .NET code |
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#6 | |||||||||||||||||||||||
|
|
My bad this is VB.NET solution, sorry I will try to rewrite it on VBA but I' not sure I'll do it Wait for tomorrow Sorry, buddy ![]() |
|||||||||||||||||||||||
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#7 |
|
|
thank you Oleg, sure I'll wait!
|
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#8 | |||||||||||||||||||||||
|
|
Unfortunately there are no chances to solve such problem with use of pure VBA methods . The instruction: Keep a file.LSP in a working directory, for example as alinks.lsp Open drawing Go to the menu Tools-> AutoLisp-> Load Application Find in a dialogue window the kept file alinks.lsp and specify it He will be loaded and carry out all actions automatically Then you can open and use my VBA a code Good luck! VBA:
VBA tags courtesy of www.thecodenet.com
here is AutoLisp code VBA:
VBA tags courtesy of www.thecodenet.com
|
|||||||||||||||||||||||
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#9 |
|
|
some troubles.
1) when I appload alinks.lsp, following the instructions i get this error: Comand: appload alinks.lsp loaded. Comand: Enter block name: Etichetta Locale Enter attribute tag: CODICE_LOCALE ._zoom Specificare un angolo della finestra, digitare un fattore di scala (nX o nXP) o [Tutto/Centrato/Dinamico/Estensioni/Precedente/scAla/Finestra/Oggetto] <tempo reale>: _e Comand: Select desired blocks >> Error! no function definition: VLAX-ENAME->VLA-OBJECT 2) when i run vba code it seems it can't get Extension Dictionary for the attribute attObj. I really hope this is not so difficult to solve. I attach my files if these could be of help. |
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#10 | |||||||||||||||||||||||
|
|
Hi Ale First you did not copied lisp code completely this line at the very top: is very important, it will be upload ActiveX dynamic libraries and its functions from AutoCAD program folder Secondly, in your drawing I have not found a blocks 'Etichetta locale' with attributes CODICE_LOCALE that has fields - every attribute just with value of 'XXXX', by this reason the lisp command will be return just empty CSV file So add a line of code above, populate 1-2 block attribute with fields and try again Hey, this drawing is very familiar to me, buddy ![]() Let me know the result after test |
|||||||||||||||||||||||
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#11 | |||||||||||||||||||||||
|
|
sorry for the first line. now lisp works. Also VBA code seems to work!!!! Yes the file! it is the only file I had to send you and to test because today i'm not in my office, so I downloaded from my previous post. Of course you know it! Thank you so much. Next Monday I'll try to suit it to my needs. Bye |
|||||||||||||||||||||||
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#12 |
|
|
Alright, I'll wating for result
of testing it on your working drawing See you Monday |
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#13 |
|
|
here test result: working perfectly!
I changed the lisp code in order to suit to my needs (the variables "Etichetta Locale" and "Area Stanza" are given by default). the strange thing is that the original code works for this line but this update doesn't work and I don't understand why. But this is another issue... Thank you Oleg. |
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#14 | |||||||||||||||||||||||
|
|
You're welcome ![]() You have to zoom drawing to extents before selection, and define selection mode explicitly, Something like, i.e.: VBA:
VBA tags courtesy of www.thecodenet.com
|
|||||||||||||||||||||||
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#15 |
|
|
I did do ZoomExtents. this is original code (sound it familiar to you?
)VBA:
VBA tags courtesy of www.thecodenet.com
I Added the following lines instead of the last original sentence VBA:
VBA tags courtesy of www.thecodenet.com
The selection gets the blocks but in such a way that is different from the original code... |
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#16 | |||||||||||||||||||||||
|
|
Try this quick example Hope this will make a sense VBA:
VBA tags courtesy of www.thecodenet.com
|
|||||||||||||||||||||||
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#17 |
|
|
thank you very much!
For each one of the case the number of blocks results the same. Running all the code: 1st case works always. 2nd case works for some files, not for some others. 3rd case doesn't work. I can't explain why this happens, but it's good for me to work using 1st case. Thank you again for your wonderful help! ![]() |
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#18 | |||||||||||||||||||||||
|
|
Sorry, my bad the very last code must be like this: VBA:
VBA tags courtesy of www.thecodenet.com
|
|||||||||||||||||||||||
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
|
|
#19 |
|
|
thank you, I had seen it and corrected it.
Bye! |
|
Local Time: 11:09 PM
Local Date: 05-23-2013 Location:
|
|
|
|
#20 |
|
|
You're welcome
Cheers ![]() |
|
Local Time: 01:09 AM
Local Date: 05-24-2013 Location:
|
|
![]() |
| Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|


