Jump to content

Recommended Posts

Posted

Hi everybody. Here goes my first post. I'm using Autocad map 3D 2013. I dont know how to create any lisps. Thank you for any help, any is really appreciated since that i know that is really taking some of your time.

I have a .dwg file with a lot of GPS points, that were taken from the field and uploaded to our systems. The GPS points come in as blocks with attributes, Im want some of does attributes to be in a multi leader (The text area).

Is easy for me to replace the GPS points (Blocks) with a multileader that I created as a block, in which the arrow points exactly to where the gps point was located.

I use the xpress tools to replace one block for another, since that all corresponding blocks are named the same, only the attributes change, so basically the multileader now is the GPS point. The GPS has two attributes that I need. Clearance_Ft=18.5 and crossing type= driveway or anything that we are crossing.

I can also get the actual attributes Clearanace and Crossing type in a text form if I do a querry of the data.

 

After I replace the point with a multileaders I try to insert fields in to the multileader to pick up it's own attributes, that didn't work, because since that I'm inside the block multileader when I press to insert the info that I need, the attributes disappear and is just a multileader inside block editor. I try Concatenation of Block Attributes, and it didnt work, at one point the insert field it did work but it was giving me the same clearance for all the points, Lol. I knew it was wrong. If I can get this issue resolve it would save me hours of work since that, for now I have to type every clearance by hand.

When i mentioned the part that i can get the info out of the point as a text is because maybe you guys do have a better idea of how to solve the problem.

 

Again Thank you.

sample.dwg

Posted

Can you post the sample.dwg as ACAD2010 as i can't open it.

Posted
Hi everybody. Here goes my first post. I'm using Autocad map 3D 2013. I dont know how to create any lisps. Thank you for any help, any is really appreciated since that i know that is really taking some of your time.

I have a .dwg file with a lot of GPS points, that were taken from the field and uploaded to our systems. The GPS points come in as blocks with attributes, Im want some of does attributes to be in a multi leader (The text area).

Is easy for me to replace the GPS points (Blocks) with a multileader that I created as a block, in which the arrow points exactly to where the gps point was located.

I use the xpress tools to replace one block for another, since that all corresponding blocks are named the same, only the attributes change, so basically the multileader now is the GPS point. The GPS has two attributes that I need. Clearance_Ft=18.5 and crossing type= driveway or anything that we are crossing.

I can also get the actual attributes Clearanace and Crossing type in a text form if I do a querry of the data.

 

After I replace the point with a multileaders I try to insert fields in to the multileader to pick up it's own attributes, that didn't work, because since that I'm inside the block multileader when I press to insert the info that I need, the attributes disappear and is just a multileader inside block editor. I try Concatenation of Block Attributes, and it didnt work, at one point the insert field it did work but it was giving me the same clearance for all the points, Lol. I knew it was wrong. If I can get this issue resolve it would save me hours of work since that, for now I have to type every clearance by hand.

When i mentioned the part that i can get the info out of the point as a text is because maybe you guys do have a better idea of how to solve the problem.

 

Again Thank you.

 

 

OK I've access the drawing and blocks. Do you want a multileader displaying the contents of the two attributes, or must it be a multileader in a block?

Posted
OK I've access the drawing and blocks. Do you want a multileader displaying the contents of the two attributes, or must it be a multileader in a block?

 

 

Sorry for the file, here it is saved as 2010.

 

Can be a multileader or a block, it really doesn't matter.

 

Again Thank you very much.

sample.dwg

Posted

Actually, thinking about it i need a block since that I am going to replace the exact location of the GPS, and it will be easier to replace one block for another instead of manually placing a multilead at each location.

Posted

Here is a start for you just pushed for time re leader settings. This can be expanded a lot more for correct block and attribute value etc.

 

(defun c:AHleatt ( / obj bname ss pt1 pt2 atttxt)
(setq olddimsc (getvar 'dimscale))
(setvar 'dimscale 5.0)
(setq obj (vlax-ename->vla-object (car (entsel "\nPick a block"))))
(setq bname (vla-get-name obj))
(setq ss (ssget "X" (list(cons 0 "insert")(cons 2 bname))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq pt1 (vlax-safearray->list (vlax-variant-value(vlax-get-property obj 'insertionpoint))))
(setq pt1 (list (car pt1)(cadr pt1)))
(setq pt2 (polar pt1 0.0 5.75))
(foreach att (vlax-invoke obj 'getattributes)
(if (= "CLEARANCE__FT_" (strcase (vla-get-tagstring att)))
(setq atttxt (vla-get-textstring att))
)
(if (/= atttxt nil)
(command "qleader" pt1 pt2 "" 0.0 (strcat "CL=" atttxt) "")	
)
)
)
(setvar 'dimscale olddimscale)
(princ)
)
(c:AHleatt)

Posted

Try this, its not a block but a multileader. It uses your current copy of Standard ML style so this needs to be set current. I've modified the text height of this style slightly (1.5 -> 1.0).

 

The lisp inserts the multileader at the block insertion point and copies the text from the two attributes to the multileader text. Everything is automated.

 

Load the lisp and type "test".

vl-load-com)

(defun c:test (/ *error* c_doc tag_lst ss new_str att_lst blk_ip pts ml_obj)

   (defun *error* ( msg ) 
       (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
       (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nAn Error : " msg " occurred.")))
       (princ)
   );_end_*error*_defun
   
   (setq c_doc (vla-get-ActiveDocument (vlax-get-acad-object))
             ms (vla-get-modelspace c_doc)
             tag_lst (list "CROSSING_TYPE" "CLEARANCE__FT_")
   )
 (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark c_doc))
   (vla-startundomark c_doc)
 
 (ssget "_X" '((0 . "INSERT") (2 . "2") (8 . "CLEARANCE_OR_SAG")))
 (setq ss (vla-get-activeselectionset c_doc))
 
 (vlax-for blk ss
   (setq new_str ""
         att_lst nil
         blk_ip (vlax-get blk 'insertionpoint)
   )
      (foreach att (vlax-invoke blk 'GetAttributes)
     (if (member (strcase (vlax-get att 'tagstring)) tag_lst)
       (setq att_lst (cons (list (vlax-get att 'tagstring) (vlax-get att 'textstring)) att_lst))
     )
       );end_foreach (att)
   (if (= (length att_lst) 2)
     (progn
       (setq pts (vlax-make-safearray vlax-vbDouble '(0 . 5)))
       (vlax-safearray-fill pts (list (car blk_ip) (cadr blk_ip) (caddr blk_ip) (+ (car blk_ip) 6) (cadr blk_ip) (caddr blk_ip)))
       (setq new_str (strcat "Crossing Type = " (cadr (assoc "CROSSING_TYPE" att_lst)) "\\PCL = \'" (cadr (assoc "CLEARANCE__FT_" att_lst))))
       (setq ml_obj (vla-addmleader ms pts 0))
       (vla-put-layer ml_obj (vla-get-layer blk))
       (vla-put-textstring ml_obj new_str)
     )
   )  
 )
 (setq ss nil)
 (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark c_doc))
);end_defun

I've re-attached the drawing as this contains the modified multileader style

Posted

Thank you! that was quick. I will try it at work today, greatly appreciated.

 

Thank you.

 

 

 

Here is a start for you just pushed for time re leader settings. This can be expanded a lot more for correct block and attribute value etc.

 

(defun c:AHleatt ( / obj bname ss pt1 pt2 atttxt)
(setq olddimsc (getvar 'dimscale))
(setvar 'dimscale 5.0)
(setq obj (vlax-ename->vla-object (car (entsel "\nPick a block"))))
(setq bname (vla-get-name obj))
(setq ss (ssget "X" (list(cons 0 "insert")(cons 2 bname))))
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq pt1 (vlax-safearray->list (vlax-variant-value(vlax-get-property obj 'insertionpoint))))
(setq pt1 (list (car pt1)(cadr pt1)))
(setq pt2 (polar pt1 0.0 5.75))
(foreach att (vlax-invoke obj 'getattributes)
(if (= "CLEARANCE__FT_" (strcase (vla-get-tagstring att)))
(setq atttxt (vla-get-textstring att))
)
(if (/= atttxt nil)
(command "qleader" pt1 pt2 "" 0.0 (strcat "CL=" atttxt) "")	
)
)
)
(setvar 'dimscale olddimscale)
(princ)
)
(c:AHleatt)

Posted

Thank you! I'm grateful for you response and I will try it today.

 

Thank you.

 

 

 

Try this, its not a block but a multileader. It uses your current copy of Standard ML style so this needs to be set current. I've modified the text height of this style slightly (1.5 -> 1.0).

 

The lisp inserts the multileader at the block insertion point and copies the text from the two attributes to the multileader text. Everything is automated.

 

Load the lisp and type "test".

vl-load-com)

(defun c:test (/ *error* c_doc tag_lst ss new_str att_lst blk_ip pts ml_obj)

   (defun *error* ( msg ) 
       (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc))
       (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nAn Error : " msg " occurred.")))
       (princ)
   );_end_*error*_defun
   
   (setq c_doc (vla-get-ActiveDocument (vlax-get-acad-object))
             ms (vla-get-modelspace c_doc)
             tag_lst (list "CROSSING_TYPE" "CLEARANCE__FT_")
   )
 (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark c_doc))
   (vla-startundomark c_doc)
 
 (ssget "_X" '((0 . "INSERT") (2 . "2") (8 . "CLEARANCE_OR_SAG")))
 (setq ss (vla-get-activeselectionset c_doc))
 
 (vlax-for blk ss
   (setq new_str ""
         att_lst nil
         blk_ip (vlax-get blk 'insertionpoint)
   )
      (foreach att (vlax-invoke blk 'GetAttributes)
     (if (member (strcase (vlax-get att 'tagstring)) tag_lst)
       (setq att_lst (cons (list (vlax-get att 'tagstring) (vlax-get att 'textstring)) att_lst))
     )
       );end_foreach (att)
   (if (= (length att_lst) 2)
     (progn
       (setq pts (vlax-make-safearray vlax-vbDouble '(0 . 5)))
       (vlax-safearray-fill pts (list (car blk_ip) (cadr blk_ip) (caddr blk_ip) (+ (car blk_ip) 6) (cadr blk_ip) (caddr blk_ip)))
       (setq new_str (strcat "Crossing Type = " (cadr (assoc "CROSSING_TYPE" att_lst)) "\\PCL = \'" (cadr (assoc "CLEARANCE__FT_" att_lst))))
       (setq ml_obj (vla-addmleader ms pts 0))
       (vla-put-layer ml_obj (vla-get-layer blk))
       (vla-put-textstring ml_obj new_str)
     )
   )  
 )
 (setq ss nil)
 (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-endundomark c_doc))
);end_defun

I've re-attached the drawing as this contains the modified multileader style

Posted

If you need the "NOTES" attribute including in the leader text, it is a very minor adjustment to the lisp. I forgot to mention previously that this lisp will work on all the blocks named "2" on layer

"CLEARANCE_OR_SAG". There is no need to substitute block for block. If you want to delete the blocks or hide them that is also possible.

Posted

Dlanohr, after i load the lisp and i run the command test, doesn't do anything. After I loaded, when i type the command it actually doesnt show the command at all, assuming that Im doing this correct.

 

BIGAL, After I load yours, it works but is putting 3 multileaders and the same data 3 times on top of each other. I check to make sure i dint have 3 gps points on top of each other, and no I only have one.

 

I really appriciate the time you both put in. Thank you very much.

 

Is there anything i can do to fix either one to make it work?

Posted
Dlanohr, after i load the lisp and i run the command test, doesn't do anything. After I loaded, when i type the command it actually doesnt show the command at all, assuming that Im doing this correct.

 

BIGAL, After I load yours, it works but is putting 3 multileaders and the same data 3 times on top of each other. I check to make sure i dint have 3 gps points on top of each other, and no I only have one.

 

I really appriciate the time you both put in. Thank you very much.

 

Is there anything i can do to fix either one to make it work?

 

 

Are you running it in the drawing i re-attached? I used the block name "2" from this drawing (with the invisible attributes) and the layer name "CLEARANCE_OR_SAG" as part of the selectionset process. If this block or layer isn't there or the blocks aren't on this layer then will be no selectionset thus nothing will happen.

 

 

Zoom out in this drawing until the dozen or so blocks are visible the load and run the lisp.

Posted
Are you running it in the drawing i re-attached? I used the block name "2" from this drawing (with the invisible attributes) and the layer name "CLEARANCE_OR_SAG" as part of the selectionset process. If this block or layer isn't there or the blocks aren't on this layer then will be no selectionset thus nothing will happen.

 

 

Zoom out in this drawing until the dozen or so blocks are visible the load and run the lisp.

 

Oh! That is why didn't work, because the blocks do change from file to file sometimes are #2 sometimes is #6 the layer remains constant but the blocks do change the name, but when they do is the entire batch for that specific file. Like the one I try today all clearences were #6, sorry for not telling you that. Is there a way that I can make it work with any block?

 

Thank you.

Posted

dlanorh, now i dont know if im doing this correct. The name of the command is test? I'm using "test" from the lisp you posted. I uploaded the lisp and type test on the command line, but nothing is happening, and is not showing the command at all when I type it. I'm really sorry if I'm doing something wrong. I know that you are helping me.

 

Thank you

Posted
dlanorh, now i dont know if im doing this correct. The name of the command is test? I'm using "test" from the lisp you posted. I uploaded the lisp and type test on the command line, but nothing is happening, and is not showing the command at all when I type it. I'm really sorry if I'm doing something wrong. I know that you are helping me.

 

Thank you

 

OK, attached is the sample drawing and the revised lisp. Put the lisp (atts2ML.lsp) somewhere in the autocad support file path (type "_options" on commandline then click the files tab then click the "+" by Support File Search Path) This will list all the autocad search paths.

 

 

Open the attached drawing. You should see a dozen or more block nodes from the drawing you sent me. Type "_appload" on the commandline and browse to the directory where you placed the lisp file. Left click on the file then left click on the Load button. The box bottom left should now say "atts2ML.lsp successfully loaded". Click close button and check that no error messages appear on the command line. Press F2 button on keyboard to bring up the text window to check. Press F2 again to dismiss.

 

 

Type test on command line then press enter. The lisp should ask you to select an instance of the block to process. Once selected it should find and process all the similar blocks on the same layer as the block you selected. If it doesn't is there any error message? The lisp is finished once the command line prompt command: returns.

 

If you wish to change the name of the lisp "test", open the file in a text editor and go to the first line "(defun c:test ( / ..etc" and change test to anything you like, e.g. "(defun c:mylisp ( /... " Save the file and reload and type the new command name mylisp on the command line.

atts2ML.lsp

new_sample-2010.dwg

Posted

Dlanorh:

 

That is GREAT! Thank you very much, it works better than what i actually ask for. WOW!

 

Again Thank You!:D

Posted

No problem. If you need any of the tweaks mentioned in post #11 let me know.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...