Search the Community
Showing results for tags 'attribues'.
-
AutoCAD MAP3D import shape files with OD to fill attributed blocks
Sambuddy posted a topic in AutoLISP, Visual LISP & DCL
Not quite sure how to tackle this, because my options on the -mapimport is very limitted and did not completely understand ADE_ function library. When I use the dialouge box of mapimport, I do get options of "creating object data" in addition to "creating points as blocks" with the option of "getting attribute values from field". So I simply create a block and define attributes with the TAG to match the the "Attribute Table" from QGIS and everything works as it should - that is I now have blocks that show the values for each block because I selected "Get attribute values from field" on Mapimport dialouge box. Can it be possible to have a routine that automate this process to 0) select a folder that contains multiple shape files and not selected one by one 1) import the map (lines and points) 2) lines and maps to be imported with their respected Object data 3) dynamic blocks be inserted that contain attributes to show the OD values at each imported points 4) visibilities of the blocks change with values/ attributes (example: if value is Hydro then visibility A and if Telecom then visibility B)? so here on this code, I am selecting a folder and then reading the content (shape files), but then I cannot go further because -mapimport did not give me all the options needed. also Block_1 and Block_2 are just examples of a block/ currently with no visibility for the conditions stated above. I do not work with Map3D all that often so help is appreciated! ( (lambda ( / path);lstall lstseluser (defun BrowseForFolder ( / sh folder folderobject result) (vl-load-com) (setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application")) (setq folder (vlax-invoke-method sh 'BrowseForFolder 0 "" 0)) (vlax-release-object sh) (if folder (progn (setq folderobject (vlax-get-property folder 'Self)) (setq result (vlax-get-property FolderObject 'Path)) (vlax-release-object folder) (vlax-release-object FolderObject) result ) ) ) (if (null (setq path (BrowseForFolder))) ;; just in case you didnt specify a path nil (setq lstall (vl-directory-files path "*.shp" 1))) ;---------------------------------------- ;; msg - [str] Dialog label ;; lst - [lst] List of strings to display ;; bit - [int] 1=allow multiple; 2=return indexes ;; Returns: [lst] List of selected items/indexes, else nil (defun LM:listbox ( msg lst bit / dch des tmp rtn ) (cond ( (not (and (setq tmp (vl-filename-mktemp nil nil ".dcl")) (setq des (open tmp "w")) (write-line (strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select=" (if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}" ) des ) (not (close des)) (< 0 (setq dch (load_dialog tmp))) (new_dialog "listbox" dch) ) ) (prompt "\nError Loading List Box Dialog.") ) ( t (start_list "list") (foreach itm lst (add_list itm)) (end_list) (setq rtn (set_tile "list" "0")) (action_tile "list" "(setq rtn $value)") (setq rtn (if (= 1 (start_dialog)) (if (= 2 (logand 2 bit)) (read (strcat "(" rtn ")")) (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")"))) ) ) ) ) ) (if (< 0 dch) (unload_dialog dch) ) (if (and tmp (setq tmp (findfile tmp))) (vl-file-delete tmp) ) rtn ) (if (not (= lstall nil)) (setq lstseluser (LM:listbox "Select one or more shape files (Ctrl or Shift):" lstall 1)) ) ;---------------------------------------- (if (not (= lstall nil)) (progn (alert (vl-prin1-to-string lstseluser)) ) ) ) ) -
I wonder if the code CountAttributeValues.lsp http://www.lee-mac.com/countattributevalues.html can be modified so that it shows in a column tags of block. I will use it in preparing MTO in electrical drawings. For example there may exist 10 blocks tag=breaker value=10A 8 blocks tag=fuse value=10A At the moment the result of running the program is value =10A....Total=18 But i want the result be as follow : tag=breaker...value=10A....Total=10 tag=Fuse...value=10A....Total=8 Thanks a lot
-
Hello Everyone, I'm working on a GIS Application which is running with AutoCAD, in that we are placing some lines and structures, while placing that the annotation will be placced automatically middle point of that poly line. after that we need to align that as per the below image. is there any possible to align the blocks automatically. steps would be Select two Blocks--->Select the Line then the blocks should be alined automatically as per the below image. can anyone help me on this. Thanks in advance. Sample.dwg
-
Hello, I am looking for a lisp that will allow me to increment an attribute in a block from one block to the next by doing a window selection. The lisp that I have now that I got from Chaitanya Chikkala (see below) works great, but I have to select each block individually. With 2000+ blocks it is easy to make a mistake. When I window select with it, it numbers them as they were added to the drawing. This does not work for me because multiple people work on drawings and then are combined into a master drawing so the order is wrong. Is there a way for a direction to be added, even if it is just along the x or y axis? Or is there a lisp that already does this? Any help is very much appreciated. (defun c:incr (/ ent obj x i ST_STR) (command "._undo" "_be") (SETQ ST_STR1 (GETSTRING "\nENTER STARTING NUMBER OF THE SEQUENCE(ANY ALPHABET/WORD)")) (SETQ ST_STR (GETSTRING "\nENTER STARTING NUMBER OF THE SEQUENCE(ANY INTEGER)")) (vl-load-com) (setq i 0) (prompt "\nSelect blocks one at a time and in order") (SETQ BLOCK_LIST (SSGET)) (SETQ BLOCK_LIST (FORM_SSSET BLOCK_LIST)) (while (< I (LENGTH BLOCK_LIST)) (SETQ ST_STR (STRCAT "" ST_STR)) (SETQ TEMP_ELE (NTH 0 (ATTRIBUTE_EXTRACT (NTH I BLOCK_LIST)))) (SETQ TEMP_ATTRIBUTE (STRCAT ST_STR1 ST_STR)) (SETQ TEMP_TAG (NTH 0 TEMP_ELE)) (MODIFY_ATTRIBUTES (NTH I BLOCK_LIST) (LIST TEMP_TAG) (LIST TEMP_ATTRIBUTE)) (SETQ ST_STR (ITOA (+ (ATOI ST_STR) 1))) (setq i (+ i 1)) ) (command "._undo" "_e") (princ)) (DEFUN FORM_SSSET (SSSET / I TEMP_ELE LIST1) (SETQ I 0) (SETQ TEMP_ELE NIL) (SETQ LIST1 NIL_) (WHILE (< I (SSLENGTH SSSET)) (SETQ TEMP_ELE (SSNAME SSSET I)) (SETQ LIST1 (CONS TEMP_ELE LIST1)) (SETQ I (+ I 1)) ) (REVERSE LIST1) ) (DEFUN ATTRIBUTE_EXTRACT (ENTNAME / ENT_OBJECT SAFEARRAY_SET I LIST1) (SETQ SAFEARRAY_SET NIL) (SETQ ENT_OBJECT ENTNAME) (SETQ ENT_OBJECT (VLAX-ENAME->VLA-OBJECT ENT_OBJECT)) (IF (= (VLAX-GET-PROPERTY ENT_OBJECT "HASATTRIBUTES") :VLAX-TRUE) (PROGN (SETQ SAFEARRAY_SET (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE (VLAX-INVOKE-METHOD ENT_OBJECT "GETATTRIBUTES") ) ) ) (SETQ I 0) (SETQ LIST1 NIL) (WHILE (< I (LENGTH SAFEARRAY_SET)) (SETQ LIST1 (CONS (LIST (VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TAGSTRING") (VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TEXTSTRING") ) LIST1 ) ) (SETQ I (+ I 1)) ) (SETQ LIST1 (REVERSE LIST1)) (SETQ LIST1 (SORT_FUN LIST1 0 0))) (SETQ LIST1 NIL) )LIST1 ) (DEFUN MODIFY_ATTRIBUTES (ENTNAME IDENTIFIER VALUE / TEMP_ELE ENT_OBJECT SAFEARRAY_SET I J) (SETQ SAFEARRAY_SET NIL) (SETQ ENT_OBJECT ENTNAME) (SETQ ENT_OBJECT (VLAX-ENAME->VLA-OBJECT ENT_OBJECT)) (IF (= (VLAX-GET-PROPERTY ENT_OBJECT "HASATTRIBUTES") :VLAX-TRUE) (PROGN (SETQ SAFEARRAY_SET (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE (VLAX-INVOKE-METHOD ENT_OBJECT "GETATTRIBUTES") ) ) ) (SETQ I 0) (SETQ J 0) (SETQ LIST1 NIL) (WHILE (< I (LENGTH SAFEARRAY_SET)) (SETQ TEMP_ELE (VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TAGSTRING")) (IF (/= (VL-POSITION TEMP_ELE IDENTIFIER) NIL) (PROGN (VLAX-PUT-PROPERTY (NTH I SAFEARRAY_SET) "TEXTSTRING" (NTH (VL-POSITION TEMP_ELE IDENTIFIER) VALUE)) )) (SETQ I (+ I 1)) ) ))) (DEFUN SORT_FUN (LIST1 FLAG1 FLAG2 /) (IF (= NIL (VL-CONSP (CAR LIST1))) (PROGN (SETQ LIST1 (INDEX_ADD LIST1)) (SETQ LIST1 (VL-SORT LIST1 '(LAMBDA (X Y) (< (CADR X) (CADR Y))) ) ) (SETQ LIST1 (MAPCAR '(LAMBDA (X) (CADR X)) LIST1)) ) (PROGN (IF (NOT (ATOM (NTH FLAG1 (NTH 0 LIST1)))) (SETQ LIST1 (VL-SORT LIST1 '(LAMBDA (X Y) (< (NTH FLAG2 (NTH FLAG1 X)) (NTH FLAG2 (NTH FLAG1 Y))) ) ) ) (PROGN (SETQ LIST1 (VL-SORT LIST1 '(LAMBDA (X Y) (< (NTH FLAG2 X) (NTH FLAG2 Y))) ) ) ) ) ) ) LIST1 )
-
Version 1.0.2
840 downloads
This small program works just like AutoCAD's GATTE express tool, with the extra option of choosing which layouts to apply attribute changes to. GATTE2 is made in lisp and uses CAB's Layout Select program to select which layouts you want. Make sure you place LayoutSelect.dcl in an AutoCAD search path or GATTE2 will not work! Required Files: gatte2.lsp LayoutSelect.dcl Both in gatte2.zip See this thread for more details. Function Syntax: gatte2 For instructions on how to run the program see here. -
I made below lisp code to have field code copied to text,dim etc. but not work on ATT thing anyone could help me with this how to make it happen that copy field code to ATT? :) (defun c:ffd () (progn (setvar "cmdecho" 0) (setvar "blipmode" 0) (vl-load-com) (progn (setq ent (entsel "select text to be copied:")) (setq egg (cdr (assoc 0 (entget (car ent))))) (setq entx (vlax-ename->vla-object (car ent))) (cond ((= egg "INSERT") (setq entp (entget (car (nentselp (cadr ent))))) (setq entr (cdr (assoc -1 entp))) (setq objid (vla-get-objectid (vlax-ename->vla-object entr))) (setq field (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).TextString>%")) ; %<\AcObjProp Object(%<\_ObjId 8796059764128>%).TextString>% ; %<\AcObjProp Object(%<\_ObjId 8796083319744>%).TextString>% ) ((= egg "DIMENSION") (setq objid (vla-get-objectid entx)) (setq field (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).Measurement \\f \"%lu2\">%")) ) ) ;%<\AcObjProp Object(%<\_ObjId 8796059773904>%).Measurement \f "%lu2">% (setq ent1 (entsel "copy to:")) (setq egg1 (cdr (assoc 0 (entget (car ent1))))) (setq entx1 (vlax-ename->vla-object (car ent1))) (cond ((= egg1 "INSERT") (setq entp (entget (car (nentselp (cadr ent1))))) (setq entr (cdr (assoc -1 entp))) (vla-put-TextString (vlax-ename->vla-object entr) field) ) ((OR (= egg1 "TEXT") (= egg1 "MTEXT")) (vla-put-textstring entx1 field) ) ((= egg1 "DIMENSION") (vla-put-TextOverride entx1 field) ) ) ) ) )
- 3 replies
-
- field code
- attribues
-
(and 1 more)
Tagged with:
-
Block attributes and enhanced attribute text. I have a drawing(s) that have blocks with attributes. I need to change the colors of the text to white. I’m trying to do this in block editor, but I CAN’T change the text. When you double click the text, the Enhanced Attribute Editor will show up, but there’s about 130 of these blocks in the drawing. How do you globally changed the attribute text globally? I CAN’T use BATTMAN. Thanks for any help,
-
I have a block with 25 and growing attributes and correspondingglobal variables. (defun attdraw (atthandle / ) ; draw out all attributes of the insert, turn them into global variablesand fill them with (setq ent (handent atthandle) ; their corresponding data. attribute name = globalvariable name. ed (entget ent) );setq (while (/="SEQEND" (dxf 0 ed)) ;whiletag value /= SEQEND (if (="ATTRIB" (dxf 0 ed)) ;make sure its an attribute (set (read(dxf 2 ed)) (dxf 1 ed)) );if (setq ent(entnext ent) ;move to the next tag ed (entgetent) ;and get entity data );setq );while );defun i update the variables in a dialog box. exiting the dialog box i update the global variables i would like to then insert the values back into theattributes using something similar. is there a way to use the attribute names as variable namesand also use the values associated with them to push them back into theattributes.