Jump to content

Match Attribute Justification (Text)


Recommended Posts

Jim Clayton

Hey guys.  I swiped super genius Lee Mac's Match Attributes Lisp and made a few tweaks to fit my personal needs.  So far I've added an AttachmentPoint, Color, and TextAlignmentPoint to the list of attribute mods.  The one final thing I want to do to it is allow for Text Justification to be matched.  I've tried several different ways and the closest I can get is for the text from one attribute to STACK on top of the source attribute.  So I think I'm missing an insertion/basepoint or something but I can't seem to figure out what I need to do to make this work.  Would greatly appreciate any help.  Thanks.

*Lisp and sample dwg attached.

*defun c:MatchAttribs

MatchAttribs.lsp Example.dwg

Link to post
Share on other sites
  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • Jim Clayton

    13

  • ronjonp

    9

  • BIGAL

    2

Top Posters In This Topic

Popular Posts

You may need to look at the relationship of the attribute to the insert point of the 1st block picked then apply that to second block based on its insertion point.    

Another question related to the the sample drawing, why don't you have a common block? That's the beauty of a block. Seems like you're making more work for yourself.

Not sure .. works fine here:  

Posted Images

You may need to look at the relationship of the attribute to the insert point of the 1st block picked then apply that to second block based on its insertion point.

 

 

  • Like 1
Link to post
Share on other sites
Jim Clayton

BigAl, Thanks for response and the help is greatly appreciated.  I think I understand what you're saying in regards to the Insertion Point being pulled from the Source attribute rather than the Destination attribute.  I've been researching/trying to add to the code but currently I haven't found the correct way to go about doing it.  Will let you know if I come up with something.  Tks.

Link to post
Share on other sites
Jim Clayton

I did try using that but it's syncing all of the blocks on the drawing.  I was looking for something more isolated that would allow me to select the objects that I wanted to sync.  I'm pretty sure I came across a second Lisp that allows me to do this (TEST2) and so I could perform all of the functions that I want to do in Two commands rather than one, but the issue I'm having now is that the MatchAttribs.lsp isn't allowing me to select more than one Destination object.  This might be a user error, it might be something in the code, i'm not sure.  But if I were to get that sorted out then I think I could probably use the two lisps two achieve what I'm trying to do.

MatchAttribs.lsp TEST 2.lsp

Link to post
Share on other sites

In Lee's code he uses nentsel so you may be better writing your own version from scratch you can double up and reselect the the block based on the nentsel point use (ssget Pt '((0 . "INSERT")) ) then (ssname ss 0) so then get the properties of the two objects seperatelly that way get attrib X & Y offset from insertion point, apply that to new block. If you get stuck ask again. 

 

 

Link to post
Share on other sites
ronjonp
3 hours ago, BIGAL said:

In Lee's code he uses nentsel so you may be better writing your own version from scratch you can double up and reselect the the block based on the nentsel point use (ssget Pt '((0 . "INSERT")) ) then (ssname ss 0) so then get the properties of the two objects seperatelly that way get attrib X & Y offset from insertion point, apply that to new block. If you get stuck ask again. 

 

 

Another question related to the the sample drawing, why don't you have a common block? That's the beauty of a block. Seems like you're making more work for yourself.

  • Like 1
Link to post
Share on other sites
Jim Clayton

It's HydraCAD...nothing makes sense and all logic is out the window.  But yes, typically I agree with you.  The tag's (blocks) are auto-generated by the program.

Link to post
Share on other sites
Jim Clayton

I figured out what the issue was.  After trying and failing multiple times to follow BigAl's instructions, I went back to Mr. Mac's site and looked at the original description for the Lisp.  It stated originally that it allowed users to select MULTIPLE attributes but I wasn't able to do that.  So I started from scratch, introduced any changes I had made one at a time, and realized that I basically broke it?  It does allow you to select multiple attributes one at a time but when I started adding to the properties, it stopped.  So, It works like a champ now.  The only issue I'm still having with it is that I'd like to be able to use a window to select multiple objects rather than do it one at a time.  So I'm trying to get that sorted out without breaking it again.  Thanks BigAl, Thanks ronjonp, and Thanks Mr. Mac. 

Link to post
Share on other sites
ronjonp

Rather than matching all the properties, why not copy the source block over the ones you want, delete the block then update the attribute content?

Link to post
Share on other sites
Jim Clayton

It might be something that I keep in mind for in the future, but for the time being I'm only a few months into learning HydraCAD and trying to become familiar with what is/is not essential.  There's a few things that are auto generated for flowing heads and performing calcs and until I get a better grasp of it I don't want to make too many changes, only try to simplify what's in front of me.  But, something to keep in mind.

Link to post
Share on other sites
ronjonp

I was thinking something like this:

(defun c:foo (/ a c e o s)
  ;; RJP » 2021-09-17
  (cond	((and (setq e (car (entsel)))
	      (= 1 (cdr (assoc 66 (entget e))))
	      (setq s (ssget ":L" '((0 . "INSERT") (66 . 1))))
	 )
	 (setq o (vlax-ename->vla-object e))
	 (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssdel e s))))
	   (setq a (vla-copy o))
	   (setq e (vlax-vla-object->ename a))
	   (setq c (vlax-ename->vla-object b))
	   (vlax-invoke a 'move (vlax-get a 'insertionpoint) (vlax-get c 'insertionpoint))
	   (foreach at (vlax-invoke c 'getattributes)
	     (vl-catch-all-apply
	       'setpropertyvalue
	       (list e (vla-get-tagstring at) (vla-get-textstring at))
	     )
	   )
	   (entdel b)
	 )
	)
  )
  (princ)
)

 

Link to post
Share on other sites
ronjonp
1 hour ago, Jim Clayton said:

Error: bad argument type: lselsetp nil

 

I guess I could see that happening if you only select one item?

Link to post
Share on other sites
Jim Clayton

The way I ran it was, load lisp, type command, select source object (single), select destination objects (multiple).  After making all the selections it throws an error.  I tried selecting single/single, then tried multiple/single, then multiple/multiple.  Those three terminate the lisp function.  Not really sure what the issue is.

Link to post
Share on other sites
Jim Clayton

Please see attached.  Thanks for the help.  If it does work like depicted above then that's exactly what I'm trying to achieve so that would be very helpful.  Tks.

Sample.dwg FOO.lsp

Link to post
Share on other sites

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