Jump to content

Recommended Posts

Posted

Hi Friends,

I require a lisp file to convert the block to Text in required format(as shown in attached Picture). actually i have lots of blocks in my drawing,all to be converted to the below shown format, previous i am doing manually as in below shown steps

1. block edit

2. removing the third line text (f8007:21-24).

3. changing the font height to 2.0 & style as Arial Black

4. exiting block editor

5. using ATTSYNC command to reflect the changes made in all blocks,

6. select simillar all blocks & making rotation to 0 degree.

 

Also attached .dwg with this, please help me.

 

Thanks,

Amb.

Annotation re-arrange_1.dwg

Capture1.jpg

Posted

You're going to have to figure this one out for yourself. If you give it a try I'll help guide you along. You can start with the code from the other post.

Posted
You're going to have to figure this one out for yourself. If you give it a try I'll help guide you along. You can start with the code from the other post.

 

hi ronjonp, sorry for the late reply,i was in hometown to take care some urgent works,

actually i am not aware of this dxf codes, but as u said i tried it by editing your previously given lisp,

but its not happening,so could you please check & guide me please.

 

(defun c:Koo (/ a p s)

(entmakex '((0 . "STYLE")

(100 . "AcDbSymbolTableRecord")

(100 . "AcDbTextStyleTableRecord")

(2 . "ArialBlack")

(70 . 0)

(40 . 0.0)

(41 . 1.0)

(50 . 0.0)

(71 . 0)

(42 . 0.125)

(3 . "ariblk.ttf")

(4 . "")

)

)

(if (setq s (ssget '((0 . "insert") (2 . "CUSTOM_MPE_EQUIP_TYPE") (66 . 1))))

(foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))

(and (setq p (cdr (assoc 10 (entget b))))

(setq a (vl-some '(lambda (x)

(if (= "ADRESSE" (vla-get-tagstring x))

(vla-get-textstring x)

)

)

(vlax-invoke (vlax-ename->vla-object b) 'getattributes)

)

)

(entmake (list '(0 . "TEXT")

'(100 . "AcDbEntity")

'(67 . 0)

'(8 . "MPE_ANNO")

'(62 . 1)

'(6 . "ByBlock")

'(100 . "AcDbText")

(cons 10 p)

'(40 . 2.0)

(cons 1 a)

'(50 . 0.0)

'(41 . 1.0)

'(51 . 0.0)

'(7 . "ArialBlack")

'(71 . 0)

'(72 . 1)

(cons 11 (cdr (assoc 10 (entget b))))

'(100 . "AcDbText")

'(73 . 0)

)

)

(entdel b)

)

)

)

(princ)

)

Posted (edited)

Here's some commented code... please take some time to study it.

(defun c:goo (/ a c c2 i p s)
 ;; Create 'ArialBlack' Style
 (entmakex '((0 . "STYLE")
      (100 . "AcDbSymbolTableRecord")
      (100 . "AcDbTextStyleTableRecord")
      (2 . "ArialBlack")
      (70 . 0)
      (40 . 0.0)
      (41 . 1.0)
      (50 . 0.0)
      (71 . 0)
      (42 . 0.125)
      (3 . "ariblk.ttf")
      (4 . "")
     )
 )
 (defun _ps (str del / pos)
   (if	(setq pos (vl-string-search del str))
     (vl-remove "" (cons (substr str 1 pos) (_ps (substr str (+ pos 1 (strlen del))) del)))
     (list str)
   )
 )
 (if (setq s (ssget '((0 . "insert") (2 . "CUSTOM_MPE_EQUIP_TYPE") (66 . 1))))
   (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     ;; Get the block insertion point
     (setq p (cdr (assoc 10 (entget b))))
     ;; You have to look for the correct attribute tagnames to populate the correct information
     (foreach x (vlax-invoke (vlax-ename->vla-object b) 'getattributes)
(cond ((= "TYPE" (vla-get-tagstring x)) (setq a (vla-get-textstring x)))
      ((= "READING" (vla-get-tagstring x)) (setq c (_ps (vla-get-textstring x) "\n")))
)
     )
     (if
(progn (entmake
	 (list '(0 . "MTEXT")
	       '(100 . "AcDbEntity")
	       '(67 . 0)
	       '(8 . "MPE_ANNO")
	       '(62 . 1)
	       '(6 . "Continuous")
	       '(100 . "AcDbMText")
	       (cons 10 p)
	       '(40 . 2.0)
	       '(41 . 0.0)
	       '(46 . 0.0)
	       '(71 . 5)
	       '(72 . 5)
	       ;; Join the resultant text together
	       (cons 1
		     (if (and a c)
		       (strcat a
			       "\\P"
			       (cond ((< (length c) 3) (car c))
				     ((apply 'strcat
					     (mapcar '(lambda (x) (strcat x "\\P"))
						     (list (nth (- (length c) 2) c) (last c))
					     )
				      )
				     )
			       )
		       )
		       "Something is not right!"
		     )
	       )
	       '(7 . "ArialBlack")
	       '(11 1.0 0.0 0.0)
	       '(50 . 0.0)
	       '(73 . 1)
	       '(44 . 1.0)
	 )
       )
       ;; Delete the block
       (entdel b)
)
     )
   )
 )
 (princ)
)
;; Loads ActiveX extensions
(vl-load-com)

 

HERE is how you add code tags in the forum.

Edited by ronjonp
Posted
Here's some commented code... please take some time to study it.

(defun c:goo (/ a c i p s)
 ;; Create 'ArialBlack' Style
 (entmakex '((0 . "STYLE")
      (100 . "AcDbSymbolTableRecord")
      (100 . "AcDbTextStyleTableRecord")
      (2 . "ArialBlack")
      (70 . 0)
      (40 . 0.0)
      (41 . 1.0)
      (50 . 0.0)
      (71 . 0)
      (42 . 0.125)
      (3 . "ariblk.ttf")
      (4 . "")
     )
 )
 (if (setq s (ssget '((0 . "insert") (2 . "CUSTOM_MPE_EQUIP_TYPE") (66 . 1))))
   (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     (and ;; Get the block insertion point
   (setq p (cdr (assoc 10 (entget b))))
   ;; You have to look for the correct attribute tagnames to populate the correct information
   (foreach x (cond ((= "TYPE" (vla-get-tagstring x)) (setq a (vla-get-textstring x)))
		    ((= "READING" (vla-get-tagstring x)) (setq c (vla-get-textstring x)))
	      )
     (vlax-invoke (vlax-ename->vla-object b) 'getattributes)
   )
   ;; Now you have to parse out the string since this is a multiline attribute
   ;; This assumes only two lines exist and are separated by "\n" --> ' "F8007:21-24\nF8007:21-24 '
   (if (setq i (vl-string-search "\n" c))
     (setq c (substr c (+ 2 i)))
   )
   ;; Now you have to make MTEXT rather than TEXT so the text is stacked
   (if (entmake	(list '(0 . "MTEXT")
		      '(100 . "AcDbEntity")
		      '(67 . 0)
		      '(8 . "MPE_ANNO")
		      '(62 . 1)
		      '(6 . "Continuous")
		      '(100 . "AcDbMText")
		      (cons 10 p)
		      '(40 . 2.0)
		      '(41 . 0.0)
		      '(46 . 0.0)
		      '(71 . 5)
		      '(72 . 5)
		      ;; Join the resultant text together
		      (cons 1
			    (if	(and a c)
			      (strcat a "\\P" c)
			      "Something is not right!"
			    )
		      )
		      '(7 . "ArialBlack")
		      '(11 1.0 0.0 0.0)
		      '(50 . 0.0)
		      '(73 . 1)
		      '(44 . 1.0)
		)
       )
     ;; Delete the block
     (entdel b)
   )
     )
   )
 )
 (princ)
)
;; Loads ActiveX extensions
(vl-load-com)

 

 

Hi Ronjonp,

Thanks for your explanation, could you please send me the lisp of DXF codes, it will be useful for me to study it.

 

Also while executing the given lisp, it shows following error, could you please check it

 

; error: bad argument type: VLA-OBJECT nil

Posted
Hi Ronjonp,

Thanks for your explanation, could you please send me the lisp of DXF codes, it will be useful for me to study it.

 

Also while executing the given lisp, it shows following error, could you please check it

 

; error: bad argument type: VLA-OBJECT nil

 

Download the code again from above .. I transposed a function :oops:.

Posted
Download the code again from above .. I transposed a function :oops:.

 

Hi Ronjonp,

Thank you so much for your help, its working absolutely fine now,

 

Could you please send me the dxf codes if possible, i am so eager to learn these kind of codes

Posted
Hi Ronjonp,

...

Could you please send me the dxf codes if possible, i am so eager to learn these kind of codes

I'm not sure what you are asking for? You can start HERE for reference.

Posted
Download the code again from above .. I transposed a function :oops:.

 

 

 

 

Hi Ronjonp,

some of the blocks contains 5 lines(as shown in attached file), which i have not noticed it earlier,sorry for that..

All the blocks contains 3 lines are working fine with your lisp.

could you please help me on this.

I tried editing (setq c (substr c (+ 2 i)))

but its not happening, please help me.

 

Actually concept is i want to keep the mtext with 3 lines after completion, ( 1st line starts with 4 FO...... 2nd line starts with F8010:...... 3rd line starts with M:600......)

if block with 3 lines, i need first 2 lines,

if the block with 5 lines, i need 3 lines(including M:600.....)

 

hope you understand my requst, please help me as its urgent.

ronjonp1.dwg

ronjonpp.jpg

Posted

Replace:

(strcat a "\\P" c)

With:

(strcat a "\\P" (vl-string-subst "\\P" "\n" c))

Posted
Replace:

(strcat a "\\P" c)

With:

(strcat a "\\P" (vl-string-subst "\\P" "\n" c))

 

Hi Ronjonp,

i have tried with replacing (strcat a "\\P" (vl-string-subst "\\P" "\n" c)) ............but its not happening, its working fine with 3 lined block, but not with 5 lined block, please check the attached image, i want that blue crossed line (M:6004-6004) to be removed. Please help.

RONJONP1.PNG

Posted
Try this .. it assumes that you always want the last two lines if greater than 2 ...

(defun c:goo (/ a c c2 i p s)
 ;; Create 'ArialBlack' Style
 (entmakex '((0 . "STYLE")
      (100 . "AcDbSymbolTableRecord")
      (100 . "AcDbTextStyleTableRecord")
      (2 . "ArialBlack")
      (70 . 0)
      (40 . 0.0)
      (41 . 1.0)
      (50 . 0.0)
      (71 . 0)
      (42 . 0.125)
      (3 . "ariblk.ttf")
      (4 . "")
     )
 )
 (defun _ps (str del / pos)
   (if	(setq pos (vl-string-search del str))
     (vl-remove ""
	 (cons (substr str 1 pos) (idt_parsestring (substr str (+ pos 1 (strlen del))) del))
     )
     (list str)
   )
 )
 (if (setq s (ssget '((0 . "insert") (2 . "CUSTOM_MPE_EQUIP_TYPE") (66 . 1))))
   (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     ;; Get the block insertion point
     (setq p (cdr (assoc 10 (entget b))))
     ;; You have to look for the correct attribute tagnames to populate the correct information
     (foreach x (vlax-invoke (vlax-ename->vla-object b) 'getattributes)
(cond ((= "TYPE" (vla-get-tagstring x)) (setq a (vla-get-textstring x)))
      ((= "READING" (vla-get-tagstring x)) (setq c (vla-get-textstring x)))
)
     )
     ;; Now you have to parse out the string since this is a multiline attribute
     ;; This assumes only two lines exist and are separated by "\n" --> ' "F8007:21-24\nF8007:21-24 '
     ;; Now you have to make MTEXT rather than TEXT so the text is stacked
     (setq c (_ps c "\n"))
     (if
(entmake (list '(0 . "MTEXT")
	       '(100 . "AcDbEntity")
	       '(67 . 0)
	       '(8 . "MPE_ANNO")
	       '(62 . 1)
	       '(6 . "Continuous")
	       '(100 . "AcDbMText")
	       (cons 10 p)
	       '(40 . 2.0)
	       '(41 . 0.0)
	       '(46 . 0.0)
	       '(71 . 5)
	       '(72 . 5)
	       ;; Join the resultant text together
	       (cons 1
		     (if (and a c)
		       (strcat a
			       "\\P"
			       (cond ((< (length c) 3) (car c))
				     ((apply 'strcat
					     (mapcar '(lambda (x) (strcat x "\\P"))
						     (list (nth (- (length c) 2) c) (last c))
					     )
				      )
				     )
			       )
		       )
		       "Something is not right!"
		     )
	       )
	       '(7 . "ArialBlack")
	       '(11 1.0 0.0 0.0)
	       '(50 . 0.0)
	       '(73 . 1)
	       '(44 . 1.0)
	 )
);; Delete the block
 (entdel b)
     )
   )
 )
 (princ)
)
;; Loads ActiveX extensions
(vl-load-com)

 

 

 

Hi Ronjonp,

I tried with the revised lisp, but its showing error as ; error: no function definition: IDT_PARSESTRING

Posted
Hi Ronjonp,

I tried with the revised lisp, but its showing error as ; error: no function definition: IDT_PARSESTRING

 

Try again .. fixed above. If this does not work sorry.

Posted
Try again .. fixed above. If this does not work sorry.

 

Hi Ronjonp,

its working fine now for both kind of blocks, but the block is appearing in behind after conversion also,

please check the attached image.

RONJON2.PNG

Posted
Hi Ronjonp,

its working fine now for both kind of blocks, but the block is appearing in behind after conversion also,

please check the attached image.

 

hi Ronjonp,

kindly ignore the above ask, its absolutely working fine now, thank you so much for you Help,

Much Appreciated!!!!

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...