help - draw an adjustable frame

help - draw an adjustable frame

mihai_bantas
Enthusiast Enthusiast
1,113 Views
7 Replies
Message 1 of 8

help - draw an adjustable frame

mihai_bantas
Enthusiast
Enthusiast

Hello everyone, I have to draw an adjustable frame (automatic) with a lisp code.

 

The idea is simple (so I think)....I have a fixed point x, y (0, 900) where I need to insert the frame, but the frame must follow my last vertical line of color 8

 

I've attached a DWG file detailing my requests.


I remain deeply grateful for any suggestion of code or income support....

0 Likes
Accepted solutions (1)
1,114 Views
7 Replies
Replies (7)
Message 2 of 8

stevor
Collaborator
Collaborator
Here is a start, modified from a past. The presets match your sample DWG.
S
0 Likes
Message 3 of 8

CodeDing
Advisor
Advisor
Accepted solution

Assuming the profile line is a polyline each time, here's something quick and easy. It doesn't adjust for OSMODE or ERRORS. It uses a table and tablestyle to adjust your needs as necessary. Just a thought. Attached is a Table Style to insert into drawing, edit as you like.

 

Best,

~DD

 

(defun c:EZTABLE (/ entPro MyTable HdistPro)
;insert table from ProfileTable to adjust to length of profile polyline
(setq entPro (entsel "\nSelect Profile Polyline"))
(vl-load-com)
(setq HdistPro (- (car (vlax-curve-getEndPoint (car entPro))) (car (vlax-curve-getStartPoint (car entPro)))));gethorizontal distance of profile polyline)
(command "-table" "2" "2" "s" "ProfileTable" (list (- (car (vlax-curve-getStartPoint (car entPro))) 26.5) 900.0));create table (2 cols / 2 "rows" (1 header 1 title))(tablestyle)(inspoint)
(command "chprop" (entlast) "" "LA" "Defpoints" "");change layer to defined place
(setq MyTable (vlax-ename->vla-object (entlast)))
(vla-setcolumnwidth MyTable 0 23.0);Col 1 width
(vla-setcolumnwidth MyTable 1 (+ HdistPro 7));Col 2 width
(vla-setrowheight MyTable 0 5.3482);Row 1 height
(vla-setrowheight MyTable 1 9.6518);Row 2 height
(vla-setrowheight MyTable 2 5.0);Row 3 height
(vla-setrowheight MyTable 3 5.0);Row 4 height
(vla-settext MyTable 0 0 "Text 1");(row/col)(row text)
(vla-settext MyTable 1 0 "Text 2");(row/col)(row text)
(vla-settext MyTable 2 0 "Text 3");(row/col)(row text)
(vla-settext MyTable 3 0 "Text 4");(row/col)(row text)

(princ)

);defun
0 Likes
Message 4 of 8

mihai_bantas
Enthusiast
Enthusiast

 

Thanks a lot dkdeterding, but I have only one request if you can select the automatic profile line by LAYER NAME or COLOR.

 

I tried to change the code with     (setq entPro (ssget "x" '((0 "LWPOLYLINE")(8 "Lung-teren"))))

 

... but it did not work

 

Anyway, thank you for the answers dkdeterding and stevor

0 Likes
Message 5 of 8

CodeDing
Advisor
Advisor

I tried to change the code with     (setq entPro (ssget "x" '((0 "LWPOLYLINE")(8 "Lung-teren"))))

 


I believe those are supposed to be dotted pairs. Try..

 

~DD

 

(setq entPro (ssget "_x" '((0 . "LWPOLYLINE") (8 . "Lung-teren"))))
0 Likes
Message 6 of 8

ВeekeeCZ
Consultant
Consultant

@CodeDing wrote:

I tried to change the code with     (setq entPro (ssget "x" '((0 "LWPOLYLINE")(8 "Lung-teren"))))

 


I believe those are supposed to be dotted pairs. Try..

 

~DD

 

(setq entPro (ssget "_x" '((0 . "LWPOLYLINE") (8 . "Lung-teren"))))

You're definitely right. But keep going... 😉

 

- (ssget) returns selection set, but the original code threads entPro as a pair of entity name and sel point.

- would be (always) ss a set of single entity or possibly more?

- selection (_x) might be limited for current space (model).... 

 

Edit: Oh, just found that you're the author of the original code just you've changed the nick name... sorry for interrupting your thread.

Message 7 of 8

CodeDing
Advisor
Advisor

 

you've changed the nick name


Diggin the name change! lol

 


You're definitely right. But keep going... 😉

 

- (ssget) returns selection set, but the original code threads entPro as a pair of entity name and sel point.

- would be (always) ss a set of single entity or possibly more?

- selection (_x) might be limited for current space (model).... 

 


I love the input! I'm by no means an expert, rather just learning actually, so to get reviewed further is very useful to me! Thank you for adding these.

 

Best,

~DD

0 Likes
Message 8 of 8

CodeDing
Advisor
Advisor

@mihai_bantas wrote:

 

Thanks a lot dkdeterding, but I have only one request if you can select the automatic profile line by LAYER NAME or COLOR.

 

I tried to change the code with     (setq entPro (ssget "x" '((0 "LWPOLYLINE")(8 "Lung-teren"))))

 

... but it did not work

 

Anyway, thank you for the answers dkdeterding and stevor


I hadn't tested the updated code I sent. I have edited the original code to what I believe you're looking for. With helpful guidance from BeeKeeCZ!

 

THIS CODE IS FOR THE ASSUMPTION THAT THIS POLYLINE IS THE ONLY POLYLINE ON THIS LAYER, unless you know whether it was the first or last (or nth) polyline drawn on that layer EVERY time.. If not, at that point it would be just as easy to select the line.

 

Best,

~DD

 

(defun c:EZTABLE (/ entPro MyTable HdistPro OldOS)
;insert table from ProfileTable to adjust to length of profile polyline
(setq OldOS (getvar "Osmode"));Store snap mode
(setvar "Osmode" 0);turn off snap
(setq entPro (ssname (ssget "X" '((0 . "*POLYLINE") (8 . "Lung-teren"))) 0));Look for all polylines on that layer
(vl-load-com)
(setq HdistPro (- (car (vlax-curve-getEndPoint entPro)) (car (vlax-curve-getStartPoint entPro))));get horizontal distance of profile polyline ("car" not needed as we have stored entity name already)
(command "-table" "2" "2" "s" "ProfileTable" (list (- 0.0 26.5) 900.0));create table (2 cols / 2 "rows" (1 header 1 title))(tablestyle)(inspoint)
(command "chprop" (entlast) "" "LA" "Defpoints" "");change layer to defined place
(setq MyTable (vlax-ename->vla-object (entlast)))
(vla-setcolumnwidth MyTable 0 23.0);Col 1 width
(vla-setcolumnwidth MyTable 1 (+ HdistPro 7));Col 2 width
(vla-setrowheight MyTable 0 5.3482);Row 1 height
(vla-setrowheight MyTable 1 9.6518);Row 2 height
(vla-setrowheight MyTable 2 5.0);Row 3 height
(vla-setrowheight MyTable 3 5.0);Row 4 height
(vla-settext MyTable 0 0 "Text 1");(row/col)(row text)
(vla-settext MyTable 1 0 "Text 2");(row/col)(row text)
(vla-settext MyTable 2 0 "Text 3");(row/col)(row text)
(vla-settext MyTable 3 0 "Text 4");(row/col)(row text)
(setvar "Osmode" OldOS)
(princ)
);defun
0 Likes