Jump to content

Need help !Use lisp Create text style & dimension style.


lucas3

Recommended Posts

Hey guys,

I want use lisp to create a new Text style and a Dimension style,details as follows:

1.Create a text style with name “ggg"

font : gdt.shx ,big font : gbcbig.shx

 

0.jpg

 

2.Create Dimension style with name "custom"

 

1.jpg

 

2.1 Baseline spacing : 7 ,Extend beyond dim lines: 2.25, Offset from origin :2

2.jpg

 

2.2 Text syle :ggg ,Text height: 2.5

3.jpg

 

2.3 Create a Child style as diameter

4.jpg

 

2.4 Text alignment set to ISOstandard

5.jpg

 

The job is finally done.

6.jpg

 

please help me ! thanks very much! I'm overwhelmed with gratitude

Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • lucas3

    13

  • ReMark

    6

  • Tharwat

    4

  • MSasu

    2

Top Posters In This Topic

Posted Images

Why bother? Create the new dim style (really, how long does it take?) then drag and drop it onto a custom tool palette. One and done. Same for the text style.

Link to comment
Share on other sites

If you intend to use this in new drawings only (that it, not to adjust an existing drawing), then setting up a template with those will be an alternative solution.

Link to comment
Share on other sites

Why bother? Create the new dim style (really, how long does it take?) then drag and drop it onto a custom tool palette. One and done. Same for the text style.

 

This is just one part of the program, I want make a autodim lisp ,Must use this text style & dim style

Link to comment
Share on other sites

If you intend to use this in new drawings only (that it, not to adjust an existing drawing), then setting up a template with those will be an alternative solution.

 

Hi ,MSasu ,If you have extra time, or very boring,please help me! I'm overwhelmed with gratitude

Link to comment
Share on other sites

Let's say you create a lisp routine to do both. You then use it for the first time in a drawing. From there on out every time you need those styles they are available via the Design Center to drag and drop into a new drawing or like I previously mentioned you place them on a custom tool palette.

Link to comment
Share on other sites

(command ".-style" "Gdt" "gdt.shx,gbcbig.shx" 0 1.0 0 "n" "n" "n")
(defun MkDimStyleFrom (OldName NewName / dims ndim)
 (setq dims (vla-get-dimstyles
       (vla-get-activedocument (vlax-get-acad-object))
     )
 )
 (if (tblsearch "dimstyle" oldname)
   (progn
     (if (not (tblsearch "DimStyle" newName))
(setq ndim (vla-add dims newName))
     )
     (vla-copyfrom (vla-item dims oldname) ndim)
     (vla-put-activedimstyle dims ndim)
   )
 )
)
;;$2 augular dimensions,$3 diameter dimensions,$4 radius dimensions,$6  ordinate dimensions 
(defun mksubdimsty (name mod / dims)
 (setq dims (vla-get-dimstyles
       (vla-get-activedocument (vlax-get-acad-object))
     )
 )
 (if (not (tblsearch "dimstyle" name))
   (progn
     (vla-put-activedocument dims (vla-item dims name))
     (vl-cmdf ".dimstyle" "s" (strcat (getvar "dimstyle") mod))
   )
 )
 (princ)
)

 

This code is from "http://bbs.xdcad.net/thread-672496-1-1.html" author is st788796

 

I don't know how to use Custom Functions

Link to comment
Share on other sites

Hi ,MSasu ,If you have extra time, or very boring,please help me! I'm overwhelmed with gratitude

 

Sorry, I will not create a template for you since is very easy to do it by yourself - just do the settings you were looking for (not only the styles, but everything you will like to have available to start a new drawing) and save it as Template file (DWT). AutoCAD will point automatically to template folder; chouse a relevant name. Don't forget to make a back-up copy.

May want also to point the NEW command to this template (in Options --> Files --> Template Setting --> Default Template File Name for QNEW).

Link to comment
Share on other sites

Sorry, I will not create a template for you since is very easy to do it by yourself - just do the settings you were looking for (not only the styles, but everything you will like to have available to start a new drawing) and save it as Template file (DWT). AutoCAD will point automatically to template folder; chouse a relevant name. Don't forget to make a back-up copy.

May want also to point the NEW command to this template (in Options --> Files --> Template Setting --> Default Template File Name for QNEW).

 

I don't want a template,I need one lisp !

Link to comment
Share on other sites

I don't want a template,I need one lisp !

 

 

 

This is not a LISP-ON-DEMAND forum, everyone here VOLUNTEERS time to HELP others in their CAD related endeavors. You were already warned in a previous thread about this attitude. If you NEED a LISP, then contact someone to do this for you for a fee.

Link to comment
Share on other sites

This is not a LISP-ON-DEMAND forum, everyone here VOLUNTEERS time to HELP others in their CAD related endeavors. You were already warned in a previous thread about this attitude. If you NEED a LISP, then contact someone to do this for you for a fee.

 

I know,I not ask someone else to do,Some people are good people willing to help others,I raised this issue,If someone is willing to help, I am very grateful,If no one is willing to help, I don't insist. It doesn't matter

Link to comment
Share on other sites

What is your reluctance towards using one of the three other (simple) ways of handling the task? Yes, lisp can make repetitive tasks much easier but it is not always the best answer to every problem.

Link to comment
Share on other sites

What is your reluctance towards using one of the three other (simple) ways of handling the task? Yes, lisp can make repetitive tasks much easier but it is not always the best answer to every problem.

 

Thank you ReMark ,I don't know how to explain.

Link to comment
Share on other sites

It's like you are trying to drive a nail with a pile driver rather than a hammer. A lisp routine to create a text style and/or a dimension style seems like overkill to me.

 

Apparently you got or wrote a lisp routine that does some of what you want but you need some help with it?

Link to comment
Share on other sites

It's like you are trying to drive a nail with a pile driver rather than a hammer. A lisp routine to create a text style and/or a dimension style seems like overkill to me.

 

Apparently you got or wrote a lisp routine that does some of what you want but you need some help with it?

 

I want to create a new text style & dim style in an autolisp program and then draw an object using it.

Link to comment
Share on other sites

I want to create a new text style & dim style in an autolisp program and then draw an object using it.

 

If you had a template that already including the text and dimension styles your lisp program could start a new drawing using the template then draw the object. Wouldn't that be much more simple?

Link to comment
Share on other sites

Try this Lucas and let me know how you'd get on with it .

 

(defun Text+Dim nil
 ;; Tharwat 17. Jan. 2014     ;;
 (if (not (tblsearch "STYLE" "ggg"))
   (entmakex '((0 . "STYLE")
               (100 . "AcDbSymbolTableRecord")
               (100 . "AcDbTextStyleTableRecord")
               (2 . "ggg")
               (40 . 0.)
               (41 . 1.)
               (42 . 1.0)
               (50 . 0.)
               (70 . 0)
               (71 . 0)
               (3 . "gdt.shx")
               (4 . "gbcbig.shx")
              )
   )
 )
 ;;                            ;;
 (if (and (not (tblsearch "DIMSTYLE" "custom"))
          (tblsearch "STYLE" "ggg")
     )
   (entmakex (list '(0 . "DIMSTYLE")
                   '(100 . "AcDbSymbolTableRecord")
                   '(100 . "AcDbDimStyleTableRecord")
                   '(2 . "custom")
                   '(70 . 0)
                   '(41 . 2.5)
                   '(42 . 2.0)
                   '(43 . 7.0)
                   '(44 . 2.25)
                   '(73 . 0)
                   '(77 . 1)
                   '(78 . 
                   '(140 . 2.5)
                   '(141 . 2.5)
                   '(171 . 3)
                   '(172 . 1)
                   '(271 . 2)
                   '(272 . 2)
                   '(274 . 3)
                   '(278 . 44)
                   '(283 . 0)
                   '(284 . 
                   (cons 340 (tblobjname "STYLE" "ggg"))
             )
   )
 )
 (princ)
)

 

Usage ...

 

(text+dim)

Link to comment
Share on other sites

Try this Lucas and let me know how you'd get on with it .

 

(defun Text+Dim nil
 ;; Tharwat 17. Jan. 2014     ;;
 (if (not (tblsearch "STYLE" "ggg"))
   (entmakex '((0 . "STYLE")
               (100 . "AcDbSymbolTableRecord")
               (100 . "AcDbTextStyleTableRecord")
               (2 . "ggg")
               (40 . 0.)
               (41 . 1.)
               (42 . 1.0)
               (50 . 0.)
               (70 . 0)
               (71 . 0)
               (3 . "gdt.shx")
               (4 . "gbcbig.shx")
              )
   )
 )
 ;;                            ;;
 (if (and (not (tblsearch "DIMSTYLE" "custom"))
          (tblsearch "STYLE" "ggg")
     )
   (entmakex (list '(0 . "DIMSTYLE")
                   '(100 . "AcDbSymbolTableRecord")
                   '(100 . "AcDbDimStyleTableRecord")
                   '(2 . "custom")
                   '(70 . 0)
                   '(41 . 2.5)
                   '(42 . 2.0)
                   '(43 . 7.0)
                   '(44 . 2.25)
                   '(73 . 0)
                   '(77 . 1)
                   '(78 . 
                   '(140 . 2.5)
                   '(141 . 2.5)
                   '(171 . 3)
                   '(172 . 1)
                   '(271 . 2)
                   '(272 . 2)
                   '(274 . 3)
                   '(278 . 44)
                   '(283 . 0)
                   '(284 . 
                   (cons 340 (tblobjname "STYLE" "ggg"))
             )
   )
 )
 (princ)
)

 

Usage ...

 

(text+dim)

 

Whatever the result,all want to thank you! I will try.

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