Jump to content

Mlstyle Caps Close?


manirpg

Recommended Posts

Actually What is the entitiy codes for these points ( start & end ).

 

The Styles are stored in the ACAD_MLINESTYLE Dictionary, the cap settings (among other things) are stored in Group 70 of the Style dictionary item.

 

Example to find which properties are set:

 

(defun GetMLineStyleProps ( style / dic )
 ;; © Lee Mac  ~  10.06.10
 (if (and (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
          (setq dic (dictsearch (cdr (assoc -1 dic)) style)))
   (GetBits (cdr (assoc 70 dic)))
 )
)


;; GetBits ~  © Lee Mac
;; Returns the bit combination of a number
(defun GetBits (n / b) 
 (if (< 0 n)
   (cons (setq b (expt 2 (fix (/ (log n) (log 2)))))
     (GetBits (- n b))
   )
 )
)

 

(GetMLineStyleProps "Standard")

Link to comment
Share on other sites

Example of modifying properties...

 

;;;    1 = Fill on
;;;    2 = Display miters
;;;   16 = Start square end (line) cap
;;;   32 = Start inner arcs cap
;;;   64 = Start round (outer arcs) cap
;;;  256 = End square (line) cap
;;;  512 = End inner arcs cap
;;; 1024 = End round (outer arcs) cap

(defun PutMLineStyleProps ( style code / dic )
 ;; © Lee Mac  ~  10.06.10
 (if (and (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
          (setq dic (dictsearch (cdr (assoc -1 dic)) style)))
   (entmod
     (subst (cons 70 (boole 7 (cdr (assoc 70 dic)) code))
       (assoc 70 dic)
       dic
     )
   )
 )
)

Link to comment
Share on other sites

Hi Mr.Lee

You are using a very advanced programming language which is not known to more than 98 per cent of participators of Cadtutor and nor normal Autolisp Programmers, So would you please make your valued answers more clearer with normal autolisp functions.

 

In regard to your answer and your example,I really could not deal with most of it, although that I have been using Autolisp for about three years now.

 

And I found 70 is not belong to start or end of Mlinestyle as in Autocad DXF Help as follows;

Mline group codes

Group code
Description

100
Subclass marker (AcDbMline) 

2
String of up to 32 characters. The name of the style used for this mline. An entry for this style must exist in the MLINESTYLE dictionary.

Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary

340
Pointer-handle/ID of MLINESTYLE object

40
Scale factor

70
Justification: 0 = Top; 1 = Zero; 2 = Bottom

71
Flags (bit-coded values):

1 = Has at least one vertex (code 72 is greater than 0)

2 = Closed

4 = Suppress start caps

8 = Suppress end caps 

72
Number of vertices

 

Many Thanks

Tharwat

Link to comment
Share on other sites

I'm not sure what you mean by 'Normal AutoLISP functions' I use the functions that I need to perform the task, as for the reference, see here:

 

http://images.autodesk.com/adsk/files/acad_dxf1.pdf

 

Page 186 :)

 

That's ok. But the question is why autocad has different DXF codes as I copied from Autocad Help 2010.

Please clearify it for me.

LWPOLYLINE

ENTITIES Section

MULTILEADER
DXF Reference > ENTITIES Section > 
MLINE Expand All 
Expand all collapsed sections. 

Collapse All 
Collapse all expanded sections. 





The following group codes apply to mline entities. In addition to the group codes described here, see Common Group Codes for Entities. For information about abbreviations and formatting used in this table, see Formatting Conventions in This Reference.

Mline group codes

Group code
Description

100
Subclass marker (AcDbMline) 

2
String of up to 32 characters. The name of the style used for this mline. An entry for this style must exist in the MLINESTYLE dictionary.

Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary

340
Pointer-handle/ID of MLINESTYLE object

40
Scale factor

70
Justification: 0 = Top; 1 = Zero; 2 = Bottom

71
Flags (bit-coded values):

1 = Has at least one vertex (code 72 is greater than 0)

2 = Closed

4 = Suppress start caps

8 = Suppress end caps 

72
Number of vertices

73
Number of elements in MLINESTYLE definition

10
Start point (in WCS)

DXF: X value; APP: 3D point

20, 30
DXF: Y and Z values of start point (in WCS)

210
Extrusion direction (optional; default = 0, 0, 1)

DXF: X value; APP: 3D vector

220, 230
DXF: Y and Z values of extrusion direction (optional)

11
Vertex coordinates (multiple entries; one entry for each vertex) DXF: X value; APP: 3D point

21, 31
DXF: Y and Z values of vertex coordinates

12
Direction vector of segment starting at this vertex (multiple entries; one for each vertex)

DXF: X value; APP: 3D vector

22, 32
DXF: Y and Z values of direction vector of segment starting at this vertex

13
Direction vector of miter at this vertex (multiple entries: one for each vertex)

DXF: X value; APP: 3D vector

23, 33
DXF: Y and Z values of direction vector of miter

74
Number of parameters for this element (repeats for each element in segment)

41
Element parameters (repeats based on previous code 74)

75
Number of area fill parameters for this element (repeats for each element in segment)

42
Area fill parameters (repeats based on previous code 75)


The group code 41 parameterization is a list of real values, one real per group code 41. The list may contain zero or more items. The first group code 41 value is the distance from the segment vertex along the miter vector to the point where the line element's path intersects the miter vector. The next group code 41 value is the distance along the line element's path from the point defined by the first group 41 to the actual start of the line element. The next is the distance from the start of the line element to the first break (or cut) in the line element. The successive group code 41 values continue to list the start and stop points of the line element in this segment of the mline. Linetypes do not affect group 41 lists.

The group code 42 parameterization is also a list of real values. Similar to the 41 parameterization, it describes the parameterization of the fill area for this mline segment. The values are interpreted identically to the 41 parameters and when taken as a whole for all line elements in the mline segment, they define the boundary of the fill area for the mline segment.

A common example of the use of the group code 42 mechanism is when an unfilled mline crosses over a filled mline and mledit is used to cause the filled mline to appear unfilled in the crossing area. This would result in two group 42s for each line element in the affected mline segment; one for the fill stop and one for the fill start.

The 2 group codes in mline entities and mlinestyle objects are redundant fields. These groups should not be modified under any circumstances, although it is safe to read them and use their values. The correct fields to modify are as follows:

Mline
The 340 group in the same object, which indicates the proper MLINESTYLE object.

Mlinestyle
The 3 group value in the MLINESTYLE dictionary, which precedes the 350 group that has the handle or entity name of the current mlinestyle.

Please send us your comment about this page

Link to comment
Share on other sites

The DXF codes that you provided, were those returned by using 'entget' on an MLine object (I assume).

 

The MLine Style Settings are stored within the ACAD_MLINESTYLE Dictionary Object, contained in the Name Object Dictionary (namedobjdict).

 

This Dictionary lists all the MLineStyles defined in a drawing, and so we can search the dictionary for the style we wish to inspect.

 

The DXF codes as listed on page 186 of the reference I provided are those of the Style Dictionary entry.

 

Lee

Link to comment
Share on other sites

Look at the code I have provided - notice that the argument is not an MLine object, but rather a style name (string).

 

Look at how I retrieve the DXF codes in my posted code.

Link to comment
Share on other sites

Hi Mr Lee

 

A very nice information. So if I wanted to make an entity for designing Mline Style which code that I have to use for the Start and end of the Mline. (is it the same 70 with flag number)

 

Many Thanks

Tharwat

Link to comment
Share on other sites

Dear Lee,

Actually I am biginner for Lisp..........

How can i use ur code..........

I did't get result....

help me?

Thanks

Regards

mani

Link to comment
Share on other sites

Use the code posted in post #5 with the correct stylename and bit code combination for what you want to achieve,

 

Example for Inner Arcs at start and end:

 

(PutMLineStyleProps "Standard" (+ 32 512))

Link to comment
Share on other sites

:)Hi Lee, I am really very sorry,

becoz my achivement for this one is somthing different.

i am using one of bad route, becoz i don’t have much experience in lisp. but it helps last two years lot lot. (for preparing this taken for 3 month for me).

I know this is very simple lisp for you and others.

My target is (need lisp)

I want a hatch patten like rectangular polyline.

1.draw polyline(user input)

2.offset polyline both side (offset value user input) and erase middle line

3.connect both offset lines by polyline and join all by pedit (end to end & end to end)

5.offset out side 200mm

6.hatch it(only centre)

& ready to next process

See the attachment

Options:

1.offset both side

2.offset any one side

But How i did it in macro,

1.mline(with offset)(with end to end cap)

2.xplode

3.pjoin

4.hatch

if i am using this in to new dwg, need to close mlstyle cap manually every time, thats why i posted this thread

Help me..............

Thanks lot

Mani

Link to comment
Share on other sites

:)Hi Lee, I am really very sorry,

becoz my achivement for this one is somthing different.

i am using one of bad route, becoz i don’t have much experience in lisp. but it helps last two years lot lot. (for preparing this taken for 3 month for me).

I know this is very simple lisp for you and others.

 

My target is (need lisp)

I want a hatch patten like rectangular polyline.

 

1.draw polyline(user input)

2.offset polyline both side (offset value user input) and erase middle line

3.connect both offset lines by polyline and join all by pedit (end to end & end to end)

5.offset out side 200mm

6.hatch it(only centre)

& ready to next process

 

See the attachment

 

Options:

1.offset both side

2.offset any one side

 

But How i did it in macro,

1.mline(with offset)(with end to end cap)

2.xplode

3.pjoin

4.hatch

if i am using this in to new dwg, need to close mlstyle cap manually every time, thats why i posted this thread

 

Help me..............

Thanks lot

Mani

 

I'm a beginner as well. I don't care that my codes are simple. It works!

 

Stick with mline

 

 
[color=red] [b](...mline command here...)[/b][/color]
(while (= 1 (getvar "cmdactive"))
 (command pause)
);end while
(command "_explode" "l" "")
(command "_pedit" "m" "p" "" "" "j" "" "")
(command "-hatch" "p" "ansi31" "40" "" "s" "l" "" ""))

Link to comment
Share on other sites

MLine to PLine example:

 

(defun c:m2p ( / *error* EntNext_to_End DOC ELST ENT I MSS OV SS UFLAG VL )
 ;; MLine to PLine  ~  Lee Mac  ~  04.01.10

 (defun *error* ( msg )
   (and ov    (mapcar (function setvar) vl ov))
   (and uflag (vla-EndUndoMark doc))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (defun EntNext_to_End (ent / a)
   (if (setq ent (entnext ent))
     (cons ent (EntNext_to_End ent))
   )
 ) 

 (setq vl '("CMDECHO" "PEDITACCEPT" "QAFLAGS")
       ov  (mapcar (function getvar) vl) ss (ssadd))

 (mapcar (function setvar) vl '(0 1 0))

 (if (setq i -1 mss (ssget "_:L" '((0 . "MLINE"))))
   (progn
     (setq uFlag
       (not
         (vla-StartUndoMark
           (setq doc
             (vla-get-ActiveDocument
               (vlax-get-acad-object)
             )
           )
         )
       )
     )
     (
       (lambda ( i )
         (while (setq ent (ssname mss (setq i (1+ i))))
           (setq eLst (entlast) ss (ssadd))

           (vl-cmdf "_.explode" ent)

           (mapcar (function (lambda ( x ) (ssadd x ss)))
             (EntNext_to_End eLst)
           )

           (vl-cmdf "_.pedit" "_M" ss "" "_J" "" "")
           (setq ss nil)
         )
       )
       -1
     )
     (setq uFlag (vla-EndUndoMark doc))
   )
 )
 (mapcar (function setvar) vl ov)
 (princ)
)

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