Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

List insertion points.

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
Luís Augusto
923 Views, 13 Replies

List insertion points.


Hello everybody.
I wonder if it is possible to generate a list of strings containing the value and point of insertion of objects of type text contained in a block.
I should point out that they are not objects of type ATTRIB but of objects of type TEXT.
I apologize if this issue has already been addressed in another topic.
I intend to make the insertion of other blocks using the points of insertion of texts as references.
Any help will be appreciated.
Thank you very much.

 

Best regards, Luis Augusto

13 REPLIES 13
Message 2 of 14
pbejse
in reply to: Luís Augusto


@Luís Augusto wrote:


Hello everybody.
I wonder if it is possible to generate a list of strings containing the value and point of insertion of objects of type text contained in a block.
I should point out that they are not objects of type ATTRIB but of objects of type TEXT.
I apologize if this issue has already been addressed in another topic.
I intend to make the insertion of other blocks using the points of insertion of texts as references.
Any help will be appreciated.
Thank you very much.

 

Best regards, Luis Augusto


Resulting to this ? [on your posted sample drawing]

1,X = 0.0000,Y = -8.7710
2,X = 0.0000,Y = -3.2235

 

or

1,0.0000,-8.7710
2,0.0000,-3.2235

 

 

 

 

 

 

Message 3 of 14
Luís Augusto
in reply to: pbejse

Yes pbejse.
How can I achieve this?
Thank you.
Message 4 of 14
pbejse
in reply to: Luís Augusto


@Luís Augusto wrote:
Yes pbejse.
How can I achieve this?
Thank you.

Hang on, i will write a quick code for you. Will this be for a particular block? or a for multiple block names?

Message 5 of 14
Luís Augusto
in reply to: pbejse

Many thanks pbe.
I'll have several names, but the blocks are simple, the same way of example, without dynamic properties.

Grateful for your help.
Message 6 of 14
pbejse
in reply to: Luís Augusto


@Luís Augusto wrote:
Many thanks pbe.
I'll have several names, but the blocks are simple, the same way of example, without dynamic properties.

Grateful for your help.

Ok, here's a start. [have not yet account for rotation/scaling of the block.]

 

(defun c:pat (/ aDoc PtLst blst i e ip bn tblk Text&ipoint)
;;; 	Point At Textstring	;;;
;;	pBe Demo May2014	;;;
  
  (defun Plus (ls_ p) (mapcar '+ ls_ p))
  (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))


  (if (setq PtLst	nil
	    Text&ipoint	nil
	    ss		(ssget "_x" '((0 . "INSERT") (2 . "TESTE,otherblock")))
      )
    (repeat (setq i (sslength ss))
      (setq e  (ssname ss (setq i (1- i)))
	    ip (cdr (assoc 10 (entget e)))
	    bn (cdr (assoc 2 (entget e)))
      )
      (if (not (setq f (cadr (assoc bn PtLst))))
	(progn
	  (setq tblk (vla-item (vla-get-blocks aDoc) bn))
	  (vlax-for itn	tblk
	    (if	(eq (vla-get-ObjectName itn) "AcDbText")
	      (setq data (cons (list (vla-get-textstring itn)
				     (vlax-get itn 'InsertionPoint)
			       )
			       data
			 )
	      )
	    )
	  )
	  (setq	PtLst (cons (list bn data) PtLst)
		f     data
		data  nil
	  )
	)
      )
      (setq Text&ipoint
	     (cons
	       (mapcar '(lambda	(x)
			  (list (Car x) (plus (cadr x) ip))
			)
		       f
	       )
	       Text&ipoint
	     )
      )
    )
  )
  (foreach item	Text&ipoint
    (print item)
  )
  (princ)
)

 HTH

 

Message 7 of 14
Luís Augusto
in reply to: pbejse

pBE,

thanks for the reply.
Unfortunately the 'InsertionPoint method is returning unwanted results.
The text within the block are using the middle-center alignment, so I thought I would get the coordinates referring to 'snap-insertion.
I have attached the results for that could take a look.
Many thanks.

Message 8 of 14
pbejse
in reply to: Luís Augusto

a quick fix would be to change this

 

(vlax-get itn 'InsertionPoint)

 

to

 

(vlax-get itn  (if (zerop (vla-get-Alignment itn))
				     'InsertionPoint
				     'TextAlignmentPoint
				   )
			 )

 

HTH

Message 9 of 14
Luís Augusto
in reply to: pbejse

Thanks for the reply.
The 'InsertionPoint even being in coordinated zero, continues to bring an incorrect result for me.

For the other coordinates, the 'TextAlignmentPoint settled the matter.
I was curious, because this problem is related to the coordinate 0? Smiley Frustrated

Message 10 of 14
Luís Augusto
in reply to: pbejse

Thanks for the reply.
The 'InsertionPoint even being in coordinated zero, continues to bring an incorrect result for me.
For the other coordinates, the 'TextAlignmentPoint settled the matter.
I was curious, because this problem is related to the coordinate 0? Smiley Frustrated

Message 11 of 14
Luís Augusto
in reply to: pbejse

Thanks for the reply.
The 'InsertionPoint even being in coordinated zero, continues to bring an incorrect result for me.
For the other coordinates, the 'TextAlignmentPoint settled the matter.
I was curious, because this problem is related to the coordinate 0, could you answer me?
Message 12 of 14
pbejse
in reply to: Luís Augusto


@Luís Augusto wrote:
Thanks for the reply.
The 'InsertionPoint even being in coordinated zero, continues to bring an incorrect result for me.
For the other coordinates, the 'TextAlignmentPoint settled the matter.
I was curious, because this problem is related to the coordinate 0, could you answer me?

Are you referring to this value (1.42109e-014 -8.771 0.0) Luis?

 

(rtos (car '(1.42109e-014 -8.771 0.0)) 2 12) = "0" That is 0.0 coordinate, as for why ? maybe it has something to do with logarithm or what not, i am not sure

 

If it bothers you that much maybe we can work thing out, what are you planning to do with the result anyway?

Message 13 of 14
Luís Augusto
in reply to: pbejse

Hello pBE.
I think I was wrong to do my tests, I'm sorry for that. Smiley Sad
The result is as I expected, I think I can now continue the routine that I'm sketching out.
I'm trying to write a code that reads the values of the attributes, then create a block using the entmake and then makes the insertion of the block over the text contained in the block.
The creation of the block with entmake is ready, now I need to read the information in the block for each attribute and generate a block and do the insert.
Thank you for writing the code for me, I greatly appreciate your help.

 

Regards, Luis Augusto.

Message 14 of 14
pbejse
in reply to: Luís Augusto


@Luís Augusto wrote:

Hello pBE.
....Thank you for writing the code for me, I greatly appreciate your help...

 

Regards, Luis Augusto.


Good for you Luis, glad you had it sorted

 

You are welcome, one is glad to be of service smileyvery-happy:

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost