Help need to make a lisp

Help need to make a lisp

WITHSEETHAL
Community Visitor Community Visitor
1,130 Views
14 Replies
Message 1 of 15

Help need to make a lisp

WITHSEETHAL
Community Visitor
Community Visitor

I have a multi point poly line, need to fix strech block on each as given drawing and delete the polyline. is that possible? 

 

WITHSEETHAL_0-1722112890770.png

 

0 Likes
1,131 Views
14 Replies
Replies (14)
Message 2 of 15

ec-cad
Collaborator
Collaborator

Not to be 'funny', but why not make the LWPolyline thickness bigger ?

 

ECCAD

 

0 Likes
Message 3 of 15

Sea-Haven
Mentor
Mentor

So you must have a rectang for each segment is that correct ? Can be done lots of offset and cap lines code out there. Just need to be changed to get vertices and repeat.

0 Likes
Message 4 of 15

ec-cad
Collaborator
Collaborator

OK, I have it working. Had trouble since your block 'pipe' has Vertical Height at 110, and Horizontal at 100.

Needed to locate the 'midpoint' of each Vector and insert at (scale / 100) or (scale / 110), depending on

the 'angle' of the Vector. I think I have it right. Give it a whirl, load the lisp, and type DOIT to run.

 

Cheers,

 

ECCAD

 

0 Likes
Message 5 of 15

Kent1Cooper
Consultant
Consultant

I think this could be fairly simple, but what I have in mind would require that the Block be better defined.  Its insertion point is off-center -- when Inserted at scale factors of 1 and rotation of 0:

Kent1Cooper_0-1722345074960.png

With a Block definition with the insertion point actually in the middle, I can picture an easy way to do what you're asking.

 

But it would also involve "plain" Insertions, using the lengths of the Polyline segments to calculate the X scale factor, rather than having them all at X scale factors of 1 with dynamically stretched ends as in your sample.  Is that acceptable?  It has the benefit that you can pick one and look at the Properties palette to see its length in the X scale factor, which you can't do in the sample drawing.

Kent Cooper, AIA
0 Likes
Message 6 of 15

ec-cad
Collaborator
Collaborator

Kent,

As always, on top of it. I did check the Horizontal / Vertical dim's, but did not check the 'Insertion Point'.

Is off to right about 0.5122 units out of 100.0. So when inserting (and 'stretching'), the ends do not get

placed exactly where they should be, given a scale factor / 2.0. So, I rebuilt the block 'pipe' (attached).

And rewrote the code to accomodate. The dim's of the block are now 100x100, with the insertion point

on center. I don't know if that block was built that way, to accomodate for a flange or whatever. So,

OP, don't use it if that's the case. !

 

ECCAD

0 Likes
Message 7 of 15

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... With a Block definition with the insertion point actually in the middle, I can picture an easy way to do what you're asking.

But it would also involve "plain" Insertions, using the lengths of the Polyline segments to calculate the X scale factor.....


Subject to that caveat, something like this [in simplest terms, lightly tested]:

 

(defun C:PL2PIPES (/ gpap ss n pl m)
  (defun gpap (par) (vlax-curve-getPointAtParam pl par))
  (setvar 'clayer "pipe")
  (if (setq ss (ssget "_:L" '((0 . "*POLYLINE") (8 . "pipe root"))))
    (repeat (setq n (sslength ss))
      (setq pl (ssname ss (setq n (1- n))))
      (repeat (setq m (fix (vlax-curve-getEndParam pl)))
        (command "_.insert" "pipe"
          "_X" (/ (distance (gpap m) (gpap (1- m))) 100)
          "_non" (gpap (- m 0.5)); insertion point
          "_non" (gpap m); rotation
        ); command
        (setq m (1- m))
      ); repeat
      (entdel pl)
    ); repeat
  ); if
  (command "_.layerp")
  (prin1)
); defun

 

It works on open or closed Polylines, "heavy" or "lightweight."  Of course, it's suitable only to Polylines made up of only line segments -- your Block approach to pipe segments couldn't handle arc segments no matter what, anyway.

And it can use all the usual bells and whistles [*error* handling, creating the Layer if needed, Undo begin/end wrapping, etc.) and maybe some specialized ones [e.g. verify only line segments].

Kent Cooper, AIA
Message 8 of 15

ec-cad
Collaborator
Collaborator

Kent,

I see (command "_.layerp") ?

Never saw that one before, is that 'layer' Previous ?

 

ECCAD

0 Likes
Message 9 of 15

Kent1Cooper
Consultant
Consultant

@ec-cad wrote:

I see (command "_.layerp") ?

Never saw that one before, is that 'layer' Previous ?


It's in there [in Help, that is].

Kent Cooper, AIA
0 Likes
Message 10 of 15

pendean
Community Legend
Community Legend

@ec-cad wrote:

Kent,

I see (command "_.layerp") ?

Never saw that one before, is that 'layer' Previous ?

 

ECCAD


https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-F266407A-0894-4930-9544-8D4087FD66B9#:~:text=....

 

 

0 Likes
Message 11 of 15

ec-cad
Collaborator
Collaborator

See also sys var 'LAYERPMODE'.

🙂

Correction. LAYERPMODE is a command, not a system variable. 

Thanks Kent.

 

0 Likes
Message 12 of 15

Kent1Cooper
Consultant
Consultant

@ec-cad wrote:

See also sys var 'LAYERPMODE'.


I wasn't aware of that one.  [Curiously, while it sure looks like a System Variable name, and its effect seems exactly like a System Variable, it isn't one -- it's really a Command, at least in Acad2020 that I have here]

Kent Cooper, AIA
0 Likes
Message 13 of 15

Sea-Haven
Mentor
Mentor

@WITHSEETHAL your turn answer the questions please.

0 Likes
Message 14 of 15

komondormrex
Mentor
Mentor

@Kent1Cooper

@ec-cad 

what's the use of pipe's scaling by X or Y, while op definitely imo wants to set and later get that block's length dynamic property, namely distance1?

0 Likes
Message 15 of 15

Sea-Haven
Mentor
Mentor

If it's a pline of straights then distance is just that between vertices. No need for block.

0 Likes