Jump to content

Recommended Posts

Posted

I'm working on a new Lisp that i want as little input as possible to put together, but i am stuck as to why my code is not working.

 

I have chosen an Entity1, "SetQ 1" a certain DXF Group code Assoc Value

then i chose a Entity2 and "SetQ 2" its same Assoc Value

 

now i try to modify Entity1's Assoc Value by using

(Setq Change (subst AssocV2 AssocV Change))

(Entmod Change)

 

but the Entity does not change, i don't get errors just no action.

What would be a good way of changing an entity's Assoc value?

 

I don't post my code cuz i don't want the solution, i just want to be steered in the right direction.

 

Thanks

Posted
What is that entity name ? and what are you trying to subst & entmod ?

 

I don't want to say too much, but an example that could be kind of similiar would be that of MatchProperties

 

where you select a LWPolyline with Global width, "Assoc 43", and change the Assoc 43 value of a new LWPolyline.

 

I'm not trying to modify LWPolylines with my lisp, it doesn't involve them at all, but that would be my example.

 

in essence, how would you write a lisp where you select a LWPoly first and select the desired width second (reverse of MA). again, my lisp has nothing to do with LWPolys.

 

After i find how to write my code, i will post it and describe what it does.

 

Thanks. i know i make my own life complicated.

Posted

Why not make your life easier and search the WWW for (entmod). There must be thousands of valid examples out there.

Posted
Why not make your life easier and search the WWW for (entmod). There must be thousands of valid examples out there.

 

I have, i've done countless searches, tried to figure it out myself, when i couldn't, i came here. I've searched entmod, subst, cons, assoc. I've used different boolean expression combinations with different key words. My code doesn't give me any errors at all, but it also doesnt modify Entity number 1. Thanks

Posted
My code doesn't give me any errors at all, but it also doesnt modify Entity number 1.

 

Post what you have tried.

Posted

After taking a break, and clear my head, i was able to get it to work. I call it, "Match Block Rotation".

And while it works, i wan't able to get it to be error free.

Selecting the first block is "user error" free; if i select nothing, or something that is not a block it gives me the right messages, but on the second block, while it does give me the correct "user error" messages, the lisp resets to the beginning and i have to re-pick the first block.

if I press enter for the second block, it gives me a bad argument, not really an issue since pressing enter will not be common practice, but pressing enter before selecting even the first blocks just quits the lisp.

 

another thing i noticed is that it wont rotate attributes, big issue. and i wish the final product of this lisp would let me select multiple blocks at a time to match to desired block rotation.

 

I want to thank everyone for their time. your knowledge sharing is greatly appreciated.

 

Below is my code. Criticize as much as you like, that's how i learn. thanks.

 

 

(defun c:MBR ( / ent enx enr ent2 enx2 enxr2 newr)
(setvar 'errno 0)
(while (/= 52 (getvar 'errno))
	(setvar 'errno 0)
	(setq ent (car (entsel "\nPick a Block to Rotate<exit>: ")))
	(cond
		(   (= 7 (getvar 'errno))
			(prompt "\nNothing Selected.")
		)
		(   (null ent)
			(prompt "\nExit.")
		)
		(   (/= "INSERT" (cdr (assoc 0 (setq enx (entget ent)))))
			(prompt "\nSelected object is not a BLOCK.")
		)
		(   (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 enx)))))))
			(prompt "\nSelected BLOCK is on a locked layer.")
		)
			(if ent (setq ent2 (car (entsel "\nWhat Block Rotation to Match <exit>: ")))
			  (cond
			  (   (= 7 (getvar 'errno))
			  	(prompt "\nNothing Selected.")
			  )
			  (   (null ent)
			  (prompt "\nExit.")
			  )
			  (   (/= "INSERT" (cdr (assoc 0 (setq enx2 (entget ent2)))))
				(prompt "\nSelected object is not a BLOCK.")
			  )
			  (   (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 enx)))))))
				(prompt "\nSelected BLOCK is on a locked layer.")
			  )
				(if ent2 (setq enxr2 (cdr (assoc 50 enx2)))
				(setq newr (entget ent))
				(setq newr (subst (cons 50 enxr2) (assoc 50 newr) newr))
				(entmod newr)
				)
			  )
			)
	)
)
(princ)
)(vl-load-com)(princ)

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