TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TJAM51 on March 06, 2006, 10:44:06 AM

Title: Match properties for pline
Post by: TJAM51 on March 06, 2006, 10:44:06 AM
I know the standard match properties will match color, linetype, etc...but is there a way for a lisp routine to match the actual pline width?



Thanks
Title: Re: Match properties for pline
Post by: T.Willey on March 06, 2006, 11:27:31 AM
Yes.  If it has a constant width, then I would use ActiveX properties, but if the width varies, then I would use the dxf code.
Quote
Select entity:  ; IAcadLWPolyline: AutoCAD Lightweight Polyline Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00b60584>
;   Area (RO) = 761.885
;   Closed = -1
;   ConstantWidth = 0.5
;   Coordinate = ...Indexed contents not shown...
;   Coordinates = (179.308 147.292 178.517 163.528 161.837 168.197 ... )
;   Document (RO) = #<VLA-OBJECT IAcadDocument 01060bf0>
;   Elevation = 0.0
;   Handle (RO) = "3A"
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 03061a54>
;   Layer = "Cloud-1"
;   Length (RO) = 99.6581
;   Linetype = "ByLayer"
;   LinetypeGeneration = 0
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2130116048
;   ObjectName (RO) = "AcDbPolyline"
;   OwnerID (RO) = 2130115848
;   PlotStyleName = "ByLayer"
;   Thickness = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 03066e40>
;   Visible = -1

Quote
Entget of entity selected:
(-1 . <Entity name: 7ef6fdd0>)
(0 . "LWPOLYLINE")
(330 . <Entity name: 7ef6fd08>)
(5 . "3A")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "Cloud-1")
(100 . "AcDbPolyline")
(90 . 5)
(70 . 1)
(38 . 0.0)
(39 . 0.0)
(10 179.308 147.292)
(40 . 0.03125)
(41 . 0.0)
(42 . 0.506788)
(10 178.517 163.528)
(40 . 0.03125)
(41 . 0.0)
(42 . 0.506788)
(10 161.837 168.197)
(40 . 0.03125)
(41 . 0.0)
(42 . 0.506788)
(10 152.275 161.588)
(40 . 0.03125)
(41 . 0.0)
(42 . 0.506788)
(10 155.367 145.425)
(40 . 0.03125) ; <----------Starting width of pline segment
(41 . 0.0)
(42 . 0.506788) ; <---------Ending width of pline segment
(210 0.0 0.0 1.0)
Title: Re: Match properties for pline
Post by: ElpanovEvgeniy on March 06, 2006, 11:35:39 AM
Entget of entity selected:
(-1 . <Entity name: 7ef6fdd0>)
(0 . "LWPOLYLINE")
(330 . <Entity name: 7ef6fd08>)
(5 . "3A")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "Cloud-1")
(100 . "AcDbPolyline")
(90 . 5)
(70 . 1)
(38 . 0.0)
(39 . 0.0)
(10 179.308 147.292)
(40 . 0.03125)
(41 . 0.0)
(42 . 0.506788)
(10 178.517 163.528)
(40 . 0.03125)
(41 . 0.0)
(42 . 0.506788)
(10 161.837 168.197)
(40 . 0.03125)
(41 . 0.0)
(42 . 0.506788)
(10 152.275 161.588)
(40 . 0.03125)
(41 . 0.0)
(42 . 0.506788)
(10 155.367 145.425)
(40 . 0.03125) ; <----------Starting width of pline segment
(41 . 0.0)          ;<---------Ending width of pline segment
(42 . 0.506788)
(210 0.0 0.0 1.0)
Title: Re: Match properties for pline
Post by: ElpanovEvgeniy on March 06, 2006, 11:38:58 AM
Code: [Select]
10
 Vertex coordinates (in OCS), multiple entries; one entry for each vertex
DXF: X value; APP: 2D point
 
40
 Starting width (multiple entries; one entry for each vertex)
(optional; default = 0; multiple entries). Not used if constant width (code 43) is set
 
41
 End width (multiple entries; one entry for each vertex)
(optional; default = 0; multiple entries). Not used if constant width (code 43) is set
 
42
 Bulge (multiple entries; one entry for each vertex) (optional; default = 0)
 
Title: Re: Match properties for pline
Post by: T.Willey on March 06, 2006, 11:53:18 AM
Thanks for the clarification Elpanov.  :-)
I did it too fast this morning. :cry: :oops:
Title: Re: Match properties for pline
Post by: TJAM51 on March 07, 2006, 07:54:19 AM
I realize the information you have given me is great but I do not fully understand it. I was hoping to obtain a routine that could be loaded and ran at the command line. I may not have been very clear about this...thanks
Title: Re: Match properties for pline
Post by: ElpanovEvgeniy on March 07, 2006, 08:05:30 AM
I realize the information you have given me is great but I do not fully understand it. I was hoping to obtain a routine that could be loaded and ran at the command line. I may not have been very clear about this...thanks

http://www.theswamp.org/index.php?topic=8878.0
 Generate a Pline from a list of points?
« Reply #7 on: 03-03-2006, 17:45:30 »
Title: Re: Match properties for pline
Post by: TJAM51 on March 07, 2006, 08:07:42 AM
If I have two plines, one is 2" wide and the other is 1" wide. I would like to pick one and then the other and the second takes on the width of the first. It would be like match properties but the width of the pline would be included.
Title: Re: Match properties for pline
Post by: Fatty on March 07, 2006, 10:15:07 AM
If I have two plines, one is 2" wide and the other is 1" wide. I would like to pick one and then the other and the second takes on the width of the first. It would be like match properties but the width of the pline would be included.

Try this one but quick and dirty...

Code: [Select]
(defun C:pm (/ obj1 obj2 prop_list val_list)
  (vl-load-com)
  (setq en1 (car (setq ent1 (entsel "\n >> Polyline #1 >>\n")))
en2 (car (setq ent2 (entsel "\n >> Polyline #2 >>\n"))))
 
  (if (and ent1 ent2)
    (progn
      (setq obj1 (vlax-ename->vla-object
       en1)
obj2 (vlax-ename->vla-object
       en2)
  )
      (if (and (wcmatch (vla-get-objectname obj1) "AcDbPolyline")
       (wcmatch (vla-get-objectname obj2) "AcDbPolyline"))
(progn
      (setq val_list
     (mapcar (function (lambda (x)
(vlax-get-property obj1 x)
       )
     )
     (setq prop_list (list
       "Color"
       "Constantwidth"
       "Layer"
       "Linetype"
       "Linetypegeneration"
       "Linetypescale"
       "Lineweight"
      )
     )
     )
      )

      (mapcar (function (lambda (x y)
  (if
    (vlax-property-available-p obj2 x T)
     (vlax-put-property obj2 x y)
  )
)
      )
      prop_list
      val_list
      )
      (vla-update obj2)
      (mapcar 'vlax-release-object (list obj1 obj2))
    )
   (alert "Incorrect object type...")
)
      )
    (alert "Both pline not selected\nyou missed...")
  )
  (princ)
)
  (prompt "\n")
  (prompt "\nType PM to execute\n")

~'J'~
Title: Re: Match properties for pline
Post by: GDF on March 07, 2006, 11:00:14 AM
Using 2005 and 2006 matchproperties will match pline width, linetype, layer.....

Gary
Title: Re: Match properties for pline
Post by: TJAM51 on March 07, 2006, 11:10:29 AM
I am using 2002 lt. I use Lt-extender to run lisp. The routine above which I appreciate deeply seems not to work. I receive the following error message....


Command: ; error: bad argument type: numberp: nil


Title: Re: Match properties for pline
Post by: T.Willey on March 07, 2006, 11:18:19 AM
See if this will work for you.  All it will do is match the constant width of one pline to another.

Code: [Select]
(defun c:PlMatchWidth (/ Sel Obj1 Obj2)

(vl-load-com)
(and
 (setq Sel (entsel "\n Select polyline with width desired: "))
 (setq Obj1 (vlax-ename->vla-object (car Sel)))
 (setq Sel (entsel "\n Select polyline to assign new width to: "))
 (setq Obj2 (vlax-ename->vla-object (car Sel)))
 (if
  (and
   (vlax-property-available-p Obj1 'ConstantWidth)
   (vlax-property-available-p Obj2 'ConstantWidth)
  )
  (vla-put-ConstantWidth Obj2 (vla-get-ConstantWidth Obj1))
 )
)
(princ)
)
Title: Re: Match properties for pline
Post by: Fatty on March 07, 2006, 11:50:28 AM
I am using 2002 lt. I use Lt-extender to run lisp. The routine above which I appreciate deeply seems not to work. I receive the following error message....


Command: ; error: bad argument type: numberp: nil




I have copied this listing I sent here, then I loaded them
on my computer and this works fine for me
but I use A2005 eng. only


~'J'~
Title: Re: Match properties for pline
Post by: Kerry on March 07, 2006, 05:14:44 PM
< .. snip .. >
http://www.theswamp.org/index.php?topic=8878.0
 Generate a Pline from a list of points?
« Reply #7 on: 03-03-2006, 17:45:30 »

Evgeniy,
Try this when you want to LINK to a POST REPLY


Title: Re: Match properties for pline
Post by: ElpanovEvgeniy on March 07, 2006, 05:23:01 PM
>Kerry Brown
Thanks! :-)
Title: Re: Match properties for pline
Post by: Kerry on March 07, 2006, 05:25:30 PM
My pleasure.

be well,
Kerry.
Title: Re: Match properties for pline
Post by: Serge J. Gianolla on March 08, 2006, 04:11:52 PM
TJAM51,

Using LT2004 + LTE, no drama upon loading pm or PlMatchWidth. I doubt the problem is LT [yes there were problems with plines in 2000], but 2004 & 2002 are similar - besides the obvious. I'd suspect LTE version you are using. I have not bothered installing latest one, so still using the Jan. 06 one and no probs when loading.

As for running the routines, pm does nothing and 2nd one displays error message! Do not have time for more investigating.
HTH