Jump to content

Draw Polyline with Specified Max. Length & Insert Text For Length


JCYK

Recommended Posts

Sometimes having a go your self is part of the learning curve just google "pline field lisp autocad" lots of examples. Its only a few lines that is required it about writing the correct string to the text 

 

This is an example of the string each object has a ID %<\AcObjProp Object(%<\_ObjId 990441952>%).Length \f "%lu2%pr1">%

Link to comment
Share on other sites

Yes I have googled that but still have no clue how all these coding works and how I could modify them. Anyway I've just started to learn Lisp routine from zero whenever I have free time, an interesting journey I must say, and probably one day I would be able to do that. Thank you!

Link to comment
Share on other sites

Try this change just replace the put

 

(vla-put-TextString txt (strcat  "%<\\AcObjProp Object(%<\\_ObjId "
                          (itoa (vla-get-Objectid pl)) ">%).Area \\f \"" "%lu2%pr2" "\">%"
                         ))

 

Link to comment
Share on other sites

  • 2 weeks later...

You are right...

 

Hi @Jonathan Handojo, I didn't want to bother you again as you have helped me a lot. But I guess this is my last resort and you are actually the best and right person on this as the lisp was written by you...

 

As mentioned in my earlier post I was wondering is it possible to enhance the lisp by having the length text to be linked to the polyline (unless someone explode it) such that when one adjusts the polyline vertex which will change the length (but still has a cap to the original specified max. length, if possible), the length text displayed will be automatically updated accordingly? 

 

Thank you! 🙏 :)

Link to comment
Share on other sites

Sorry, I've been off for quite some time and lost track of what's happening here as I've been very busy myself.

 

If you change the vertex of the end point of the polyline, doesn't that mean that you also want to change the location arrowhead as well? if that's so, it's gonna be one hell of a massive code change using reactors and I'm not very excellent at that.

 

 

10 hours ago, JCYK said:

(but still has a cap to the original specified max. length, if possible)

 

Changing the polyline such that the length does not exceed a certain number is possible using LISP, but it's a very tedious task. It's like creating a STRETCH command on the polyline without exceeding the line limit (or in other words, as good as creating a new LISP command).

 

However, I can amend the length using fields as how BIGAL have suggested.

Link to comment
Share on other sites

I would add a move and update version just redoing the end arrow. Much easier than a reactor. Is it just a update rotation of last point angle ?

 

 

Edited by BIGAL
Link to comment
Share on other sites

15 hours ago, Jonathan Handojo said:

 

On 6/3/2020 at 7:45 PM, JCYK said:

(but still has a cap to the original specified max. length, if possible)

 

Changing the polyline such that the length does not exceed a certain number is possible using LISP, but it's a very tedious task. It's like creating a STRETCH command on the polyline without exceeding the line limit (or in other words, as good as creating a new LISP command).

 

However, I can amend the length using fields as how BIGAL have suggested.

 

Okay, for amending polyline part it's fine not to keep to the limit then. If the live display of length will still be present (when adjust the polyline) I could still look at it to know if the max length has been reached. 

 

Would be great if you can help amend the length using fields! 😃 

 

15 hours ago, Jonathan Handojo said:

If you change the vertex of the end point of the polyline, doesn't that mean that you also want to change the location arrowhead as well? if that's so, it's gonna be one hell of a massive code change using reactors and I'm not very excellent at that.

 

Yes you are right on the arrowhead... I didn't know it will be a massive code change 😛 Hope someone has a simpler solution on this to share? Thank you!

 

 

Link to comment
Share on other sites

4 hours ago, JCYK said:

 

Hope someone has a simpler solution on this to share? Thank you!

 

 

 

 

just $0.02 idea, not sure it helps? 

1.manually place DIMALIGNED at end segment of polyline.

2.suppress all dim & ext lines, leave only one arrow & dim line at the end tip & adjust size etc..

3.replace measurement, inserting FIELD (object->length property)

   ;if last segment vertices moved, the dimension 'TEXT' & Arrow head should follow end point of last segment.

4.command: REGEN or UPDATEFIELD

 

 

  • Like 1
Link to comment
Share on other sites

Sounds like a solution.

 

Hi @Jonathan Handojo, what do you think, is this something that can be incorporated in your lisp without too much hassle? =p

 

If can be done I can try to create a dim style with customised arrowhead for you to incorporate? 

Link to comment
Share on other sites

  • 2 years later...

HI  my name is Wolter

Appologise for ma English

For many years I've been reading this  forum and learning autolisp  but I'm not able to create application to set up a layer with the command "Laymcur" then autolisp would compare the name of the layer with the name in the list where it would contain information about the thickness and line scal of polllines end start to draw. 

I am impressed with the above application and I am happy to see something like This.

 

For the short 

1. I have defun 50 poline insid draw (this is my  stndard polline).

2. I chose one polline command Laymcur ,  name of leyer  L01

3  Then I set up command polline <pl> end draw polline L01 

(|2.|; "Linetype" ;|3.|; "Line Width" ;|4.|; "Linetype Scale" ;|5.|; "Layer")

     polline will be  draw the polyline will be drawn with these parameters in this list-00

 

	      (50 "DASHED2" 10 0.2 L01)
	      (50 "DASHED" 30 0.3 L02)
		.
		.
		.
	      (50 "DASHED2" 15 1.1 L50)

Dear Sir Mr. Jonathan Handojo  I dare to address you directly and immodestly ask if it is possible😳.

How to download data from the list-00 and assign it to the current layer?

 

Best regards,

Wolter

 

 

 

 

 

 

Link to comment
Share on other sites

This is a start, change to suit your input.

 

(defun chklay (lay col lt / )
(if(not(tblsearch "LAYER" lay))
(command "-layer" "m" lay "c" col lay "lt" lt lay "")
(princ "exist")
)
(setvar 'clayer lay)
)

You can set pline width using (setvar 'plinewid x)

  • Like 1
Link to comment
Share on other sites

(setq
	trackcolor acGreen  ; <--- Polar AutoTrack color
	crosscolor acYellow ; <--- Polar Snap color 
	dets
	   '(
	     (  ;|2.|; "Linetype" ;|3.|; "Line Width" ;|4.|; "Linetype Scale" ;|5.|; "Layer" )

	     ;		^ (defun in draw)   ^			  ^			^	

	     ;( 	nil		  2			 0.2 		     DRO-Opis)
	     
	     ( nil 2 0.2 DRO-Opis )
	     ( nil 5 0.4 DRO-Naw  )
	     ( mil 1 1.0 DRO-Odw  )
	     )
	units '("m")
	)

    ;;; ------------------------------------- tblsearch ------------------------------------- ;;;

	(defun chklay (lay col lt / )
	(if(not(tblsearch "LAYER" lay))
	(princ "no exist")

	(entmake
  			pl
		     (vlax-ename->vla-object
			 (entmakex
			     (list
				 '(0 . "LWPOLYLINE")
				 '(100 . "AcDbEntity")
				 '(100 . "AcDbPolyline")
				 (cons 6 (getdet defscale "Linetype"))
				 (cons 48 (getdet defscale "Linetype Scale"))
				 '(90 . 2)
				 '(70 . 0)
				 (cons 43 (getdet defscale "Line Width"))
				 (cons 8 (getdet defscale "Layer"))
				 (cons 10 pt)
				 (cons 40 (getdet defscale "Line Width"))
				 (cons 41 (getdet defscale "Line Width"))
				 '(42 . 0.0)
				 '(91 . 0)
				 (cons 10 (polar pt 0 1))
				 (cons 40 (getdet defscale "Line Width"))
				 (cons 41 (getdet defscale "Line Width"))
				 '(42 . 0.0)
				 '(91 . 0)
				 )
			     )
			 )
	)


	)
	(setvar 'clayer lay)
	
	)

Dear Sir…
Thank you very much for your answer.

I'm "too thin in the ears" (this is saying :) ) to modify this wonderful application.
I am uploading the autolisp schema what I would like to achieve.
In the drawing I have already defined lines, I only need the polyline definition that would be encoded in autolisp.
And after doing two operations < Laymcur> & command <pl>
and setting operations via autolisp ;|3.|; "Line Width" ;|4.|; "Linetype Scale" from the list [dets]
I would start drawing the current polyline layer with the above settings.

It that is possible ?

 

Regard   

Link to comment
Share on other sites

I think take a step back and have a look at code.

 

1 pick correct settings (50 "DASHED2" 10 0.2 L01)

2 does layer L01 exist you put this code at top of your code

 

(defun chklay (lay col lt lsc / )
(if(not(tblsearch "LAYER" lay))
(command "-layer" "m" lay "c" col lay "lt" lt lay "")
(princ "exist")
)
(setvar 'clayer lay)
)

and call using (chklay lay)

 

3 If your not doing thousands of plines then maybe go back to using command if you (setvar 'plinewid x) to your value first then pass the list of points.

(setvar 'plinewid 2.0) or more correct (setvar 'plinewid (nth 2 ans)) where ans is your list.

(ahpllst lst)

(defun AHpllst ( lst / x)
(setvar 'celtype "DASHED") ; again use correct value from your list
(setvar 'plinewid 2.0)
(setvar 'ltscale 2.0)
(command "_pline")
(while (= (getvar "cmdactive") 1 )
(repeat (setq x (length lst))
(command (nth (setq x (- x 1)) lst))
)
(command "")
)
)

 

 

4 how are you picking the correct parameter list to use ?

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