Jump to content

Need some help with a couple commands


K Baden

Recommended Posts

The first one Is pretty simple, I assume, but i am just starting to learn lisp.

Basically, I am trying to change the dimstyle of all my dimensions (it is an existing dimstyle) which i got working, but this changes all of my leaders to have a text vertical position of "above", so i want to add a line in that will change it back to centered.

Now, I have this written up where it works, but its making me select the leaders i want to change.

I have a line written that i thought would select all the leaders, and then apply the change, but it doesn't to that, and requires me to grab them myself. Everything works once i grab them, but i want it to automatically select them and make the change.

That code is as follows:

 

(Defun c:dilsl ()
(setq currentdimstyle (getvar 'CROWN))
  (command "_.dimstyle" "_restore" "CROWN")
     (setvar "DIMASZ" 0.0625)        ;Arrow size
     (setvar "DIMTXT" 0.0625)        ;Text height
     (setvar "DIMSE1" 0)        ;Un-Suppress the first extension line
     (setvar "DIMSE2" 0)        ;Un-Suppress the second extension line
  (command "_.dimstyle" "_save" "CROWN" "_yes")
  (command "DimOverride" "c" "all" "")

(setq ss1
 (ssget '((0 . "LEADER"))))
  (command "DimOverride" "DIMtad" "0" "" ss1 "")

     (princ)
)

 

 

 

 

My other task is a bit more of an ask. I will attach a code that is easy to read/edit for someone like me, who really doesn't know what they're doing.

So this one, I basically want a find and replace for text and mtext that I can predefine. It is text within a larger string, but there's about 10-15 different updates on each drawing (literally thousands) that typically show up.

I have found a code within my company that does his for attributes, but i do not have the knowledge to edit it to look for text/mtext instead.

keep in mind these are not complete text/mtext strings. these are mistakes within larger strings.

Here is a little screen cap of what i'm looking at (don't mind the ugly leaders in my test drawing, refer to previous issue LOL)

snip.PNG

 

So what i want it to do is seek out "(TYP.)" and change it to "(TYP)", "SELF SUPPORT" and "S.S." and change it to just "SS", and "OCT" and change it to "OCTAGONAL".

 

I really would love for this to be done without any user input needed, mostly because i have 25 other drafters who will be using this.

 

Find and replace is not efficient for this for multiple reasons. It's on thousands of drawings, and it's typically only one occurrence on each drawing. using find and replace would be less efficient than just going in and editing each text manually.

 

Here i'll attach the code we have that only looks for attributes, maybe it could be a starting point.

 

(defun attreplace (old new / aval)
 (vlax-for n
    (vla-get-blocks
      (vla-get-activedocument
	(vlax-get-acad-object)))
   (vlax-for m n
   (if (and (= "AcDbBlockReference" (vla-get-objectname m))
     (= :vlax-true (vla-get-hasattributes m)))
(foreach a
	 (vlax-invoke m  'getattributes)
  (setq aval (vla-get-textstring a))
  (while (vl-string-search old aval) ;;<- look for string
   (setq aval (vl-string-subst new old aval )) ;;<-replace here
    )
  (vla-put-textstring a aval)
  )
     ))
     ))
	(attreplace "TECHNOLOGIES" "TECH")
	(attreplace "COMMUNICATION COMPONENTS INC." "COMM COMPONENTS")
	(attreplace "DUAL BAND" "DB")
	(attreplace "Remote Radio Head" "Rem Radio Hd")
	(attreplace "Other - With RF" "Other-W/ RF")
	(attreplace "Other - Without RF" "Other-W/O RF")
	(attreplace "COMMUNICATIONS" "COMM")
	(attreplace "COMMUNICATION" "COMM")
	(attreplace "TECHNOLOGY" "TECH")
	(attreplace "FULL BAND" "FB")
	(attreplace "MASTHEAD" "MSTHD")
	(attreplace "DUAL DUPLEX" "DD")

	(princ)
  )

 

What i LOVE about the above code is how obvious and simple adding new things into the list of predefined stuff would be. I just have literally no clue how to edit this to get it to look for text/mtext.

Link to comment
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
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...