Lisp to set polyline width

M_c3d
Advisor
Advisor

Lisp to set polyline width

M_c3d
Advisor
Advisor

Hi All,

 

I'm trying to amend a civil 3d command to set the layer and width of the polyline it creates.

 

The layer changes ok, but the plinewid doesnt apply to the polyline created.


Any ideas? 

 

Thanks in advance!

 

(command "_.undefine" "AeccCreateSurfaceWaterDrop")
(defun C:AeccCreateSurfaceWaterDrop () (setvar 'clayer "Surface Water Flow Path") (setvar 'plinewid 0.1) (command "_.AeccCreateSurfaceWaterDrop"))

0 Likes
Reply
1,715 Views
7 Replies
Replies (7)

john.uhden
Mentor
Mentor

How about after the command you change the width of (entlast)?

Or, are you sure the path isn't a 3Dpoly?  You can't change the width of those.

John F. Uhden

0 Likes

Kent1Cooper
Consultant
Consultant

I suggest you take this up in the >Civil3D Customization Forum<.  It probably has something to do with the internal workings of that AeccCreate... command, which could perhaps make a Polyline with (entmake), including a width entry [which would not  be affected by the PLINEWID setting], rather than by drawing one with a Pline command  [which would  be].  I don't have Civil3D, so I couldn't say whether the code defining that command is available, to see how it operates.

Kent Cooper, AIA
0 Likes

CodeDing
Advisor
Advisor

@M_c3d ,

 

I am actually unsure why you set the layer at the beginning of your command because it does not seem to affect the layer my flow path gets placed on. There is ALWAYS a popup box which makes the user specify the settings of the water drop:

image.png

 

Also, it seems you are correct in that the PLINEWID variable does not affect the creation of even a 2D Flow Path. And the (entlast) approach would not work since many flow paths can be created by the command in one-go.

Here is an alternative approach that I believe could work for you (you'll have to fix the command name). It's the best I can think of:

(defun C:TEST ( / ss cnt)
  (command-s "_.AeccCreateSurfaceWaterDrop")
  (if (setq ss (ssget "_X" '((0 . "LWPOLYLINE") (8 . "Surface Water Flow Path"))))
    (repeat (setq cnt (sslength ss))
      (setpropertyvalue (ssname ss (setq cnt (1- cnt))) "ConstantWidth" 0.1)
    );repeat
  );if
  (setq ss nil)
  (princ)
)

 

---EDIT---

Also, it may be noteworthy to mention, that if the purposes of this is for plotting, then I believe all of this can be accomplished by setting up proper layering (line weights). But if its primary purpose is for the user to see the width, then you can use the code approach.

 

Best,

~DD

 

0 Likes

M_c3d
Advisor
Advisor

Hi @CodeDing 

 

When using reference templates in 2020.4 the command ignores the layer that is set in the reference template.

 

In the dialog box;

 

Water Drop PathPath Layer AcDbObjectId::kNullPath Object Type 2D PolylineWater Drop

 

I'll give your suggestion a try.

 

Thanks,

0 Likes

alanjt_
Collaborator
Collaborator

That usually means the layer that was defined no longer exists in the drawing. If you set to anything else, it will work fine.

 

FYI, if you open ToolSpace settings, under Surface>Commands>CreateSurfaceWaterdrop, you can change the default layer/object settings for the water drop line - this would need to be set in the template, to apply to all drawings going forward.

However, this does not accomplish you want to set a width for the polyline. If you are to accomplish this, you'll need a command reactor to execute upon completion of a waterdrop, select the newly created waterdrop polyline and have it set your width (and layer, if you don't change in settings).

 

alanjt__0-1598469688776.png

 

0 Likes

M_c3d
Advisor
Advisor

Hi @alanjt_ the reference template had the layer added and pushed it through to the drawings but for some reason it didn't come up with it when selecting.  Tried adding layer and then setting it but it still wouldnt work.

 

I also posted in the civil 3d forum as suggested by @Kent1Cooper and @Jeff_M gave me a different lisp to get it working.  https://forums.autodesk.com/t5/civil-3d-customization/lisp-to-set-waterdrop-width/m-p/9711780/highli...

 

 

0 Likes

alanjt_
Collaborator
Collaborator

Good deal, and good solution from Jeff. I should have thought to just redefine the command. 

0 Likes