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

Combine two lisp (slect by name/rotation and replace attributes) to single

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
djurk_haas
1195 Views, 6 Replies

Combine two lisp (slect by name/rotation and replace attributes) to single

Hello,

I have found two lisp that together will do the perfect thing for me.

I wonder if it's possible to merge these two lisp's together to the perfect lisp for me.

What I want to achieve is:

- select souce block with already adjusted attribute positions (see lisp rotation)

- 'automaticly' select all the blocks in the drawing with the same name and rotation (see lisp: rotation)

- adjust these selected blocks comfom the source block (lisp AArr)

 

Thanks in advance

 

6 REPLIES 6
Message 2 of 7
pbejse
in reply to: djurk_haas


@djurk_haas wrote:

 

- select souce block with already adjusted attribute positions (see lisp rotation)

- 'automaticly' select all the blocks in the drawing with the same name and rotation (see lisp: rotation)

- adjust these selected blocks comfom the source block (lisp AArr)

 

 


Coding blind: [ minimal testing ]

 

command: combine 

Select source block:

 

(defun C:Combine ; Written by: Grrr, credits to: Lee Mac, Tharwat, pBe
<< Refer to attached file >>..

 

HTH

 

 

Message 3 of 7
djurk_haas
in reply to: pbejse

Thanks!!

 

Works great know.

Next question (to add even some more automatization) is it also possible to fix the source block?

So instead of the question to select the source object in the drawing it would be the block in the drawing that's on a specific location (x=500 y=500 z=0)

I have been trying to adjust the lisp with this piece of code: (ssget "_x" '((0 . "insert") (10 500 500 0))) but I don't get it working.

If this could work would be very great

Message 4 of 7
pbejse
in reply to: djurk_haas


@djurk_haas wrote:

Thanks!!

 

Works great know.

 

I have been trying to adjust the lisp with this piece of code: (ssget "_x" '((0 . "insert") (10 500 500 0))) but I


 

Not sure why that piece of code doesn't work. Like what we suggested on your other thread , add more filter to ensure the selection.

 

This should work:

(setq sBe (ssget "_X" '((0 . "INSERT")(66 . 1)(10 500.00 500.00 00.00))))

Or add the block name

(setq sBe (ssget "_X" '((0 . "INSERT")(66 . 1)(2 . "E00152")(10 500.00 500.00 00.00))))

Both works on the sample drawing you posted.

 

We can use rperez's sub ;

(setq sBe (_blockbypoint (trans '(500. 500. 0.) 1 0) 1e-8))

 

Added the block name option

(setq sBe (_blockbypoint (trans '(500. 500. 0.) 1 0) 1e-8 "E00152"))

 

Pick your poison. and tell us what works 

Otherwise, post the sample drawing where the above options don't work.

 

 

BTW: whats with the username? 🙂

 

Message 5 of 7
pbejse
in reply to: pbejse

or even

(setq sBe (ssget "_X" '((0 . "INSERT")(66 . 1); <-- add more filter here
			   (-4 . ">=,>=,*") (10 500.00 500.00 00.00)
			   (-4 . "<=,<=,*") (10 501.00 501.00 00.00) )))

 

HTH

 

 

Message 6 of 7
djurk_haas
in reply to: pbejse

Hello,

The lisp works fine thank you very much.

The next 'problem 'occured: i have in the same block attributes with difrent rotation.

Is it possible to put some code into the lisp that sets the rotation of specified attributes to an specific angle (before is will be placed on the right position with the existing code)

Tanks again for the help.

Tags (1)
Message 7 of 7
Dany.jee
in reply to: djurk_haas

Hello,

I am looking to combie two lisp into one.

The first lisp is to delete all attributs from block

And the second is to add predefined attributes.

 

See the Two lisp in the attached file.

 

I have no clue how to combine them..

 

Ps: + If you now how to set the alignment to center on my addattribs.lsp if would be awesome too. ( I ve tried (vlax-put def 'Alignment 4) & (vlax-put def acAlignmentmiddle) but that's not working.

 

 

Thanks in advance.

Dany

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report