Jump to content

Trim inside selected rectangles


Abrasive

Recommended Posts

6 hours ago, mhupp said:

Draftsight says it can use visual lisp Give this a test on two objects that are overlapping. should look something like this.

 

: test
Select Object
#<VLA-OBJECT IAcadCircle 0000000034136D70>
Select Object
#<VLA-OBJECT IAcadLWPolyline 0000000034138670>
(38.4875958273987 6.35534521426045 0.0 59.4778766221801 -15.5266360848402 0.0)

 

(defun C:test (/ obj1 obj2 pts-lst)
  (vl-load-com)
  (setq obj1 (vlax-ename->vla-object (car (entsel "\nSelect Object"))))
  (princ "\n")
  (princ obj1)
  (setq obj2 (vlax-ename->vla-object (car (entsel "\nSelect Object"))))
  (princ "\n")
  (princ obj2)
  (setq pts-lst (vlax-safearray->list (vlax-variant-value (vla-intersectwith obj1 obj2 acextendnone))))
  (princ "\n")
  (princ pts-lst)
  (princ)
)

 

 

 

 

RESULT:

 

: TEST

Select Object»

1 found

"(null):  (null)"

nil

 

I don't know enough about what's going on to help...

Link to comment
Share on other sites

(defun C:test (/ obj1 obj2 pts-lst)
  (vl-load-com)  
  ;(setq obj1 (vlax-ename->vla-object (car (entsel "\nSelect Object"))))
  (setq obj1 (entget (car (entsel "\nSelect Object"))))
  (princ "\n")
  (princ obj1)
  ;(setq obj2 (vlax-ename->vla-object (car (entsel "\nSelect Object"))))
  (setq obj2 (entget (car (entsel "\nSelect Object"))))
  (princ "\n")
  (princ obj2)
  (setq pts-lst (vlax-safearray->list (vlax-variant-value (vla-intersectwith obj1 obj2 acextendnone))))
  (princ "\n")
  (princ pts-lst)
  (princ)
)

Changed code to above and get this result:

(Got the lines of code from AFRALISP:)

https://www.afralisp.net/autolisp/tutorials/extended-entity-data-part-1.php

 

 

Select Object»

1 found

((-1 . <EName:  0000015bf68ef220>) (0 . CIRCLE) (5 . 12C) (330 . <EName:  0000015ba76ac600>) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . 0) (100 . AcDbCircle) (10 1122.8891695 -983.61616472 0.0) (40 . 737.83879731) (210 0.0 0.0 1.0))

Select Object»

1 found

((-1 . <EName:  0000015bf54fadd0>) (0 . LWPOLYLINE) (5 . 12A) (330 . <EName:  0000015ba76ac600>) (100 . AcDbEntity) (67 . 0) (410 . Model) (8 . 0) (100 . AcDbPolyline) (90 . 4) (70 . 1) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 140.79935327 858.08230436 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 140.79935327 -817.81849232 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 290.1666257 -817.81849232 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 290.1666257 858.08230436 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))

 Error: Invalid parameter.

 

 

Link to comment
Share on other sites

Unfortunately you need the vla-object name to work with the intersectwith function. That's what vlax-ename->vla-object is doing its converting the entity name into vla-object.

 

According to the website only version 2021 and up have that function.

https://help.solidworks.com/2023/English/api/draftsightlispreference/vlisp/vl_vlax_functions.htm?verRedirect=1

 

Maybe their is some other way to calculate interesting points but i don't know how. and with out those points I can't break/trim objects around another one.

Link to comment
Share on other sites

3 minutes ago, mhupp said:

Unfortunately you need the vla-object name to work with the intersectwith function. That's what vlax-ename->vla-object is doing its converting the entity name into vla-object.

 

According to the website only version 2021 and up have that function.

https://help.solidworks.com/2023/English/api/draftsightlispreference/vlisp/vl_vlax_functions.htm?verRedirect=1

 

Maybe their is some other way to calculate interesting points but i don't know how. and with out those points I can't break/trim objects around another one.

@mhupp Thank you so much for your time!

I have an idea that might work...

I'll try to explain.

If I can select the rectangle and offset its points to the inside by a small number say .001.

Then use those values to create a list of points.

In the routine, start the Trim command and fill the values for a fence using the new inside offsets then have the routine finalize the trim command?

 

(defun c:TBEAM (/ )
;SELECT A RECTANGLE....
  (setq RectList1 (entget (car (entsel))))
;OFFSET ITS POINTS TO THE INSIDE BY .001.....
  ;RectList2 = RectList1 - .001
;RUN THIS COMMAND.......
(command "_TRIM" "" "_F" pause pause pause) ; AFTER THE "_F" FILL THE FENCE WITH RectList2 AND FINISH

)

 

Link to comment
Share on other sites

You are correct you can select a closed  pline you make that the trim line you then offset that inwards a small amount that makes your trim line. Then do a ssget "WP" to erase objects inside. 

 

This has no VL

 

(defun c:wow ( / oldsnap ent co-ord co-ord2 pt )
(setq oldsnap (getvar 'osmode))
(setq ent (entsel "\nPick rectang "))
(setvar 'osmode 0)
(setq pt (getpoint "\nPick point inside "))
(command "offset" "0.5"  ent pt "")
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car ent)))))
(setq co-ord2 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
(setq co-ord2 (cons (last co-ord2) co-ord2))
(command "erase" (entlast) "")
(setq pt (car co-ord))
(command "trim" pt "" "F" co-ord2 "" "")
(command "erase" (ssget "WP" co-ord2) "")
(setvar 'osmode oldsnap)
(princ)
)
(c:wow)

Can be modified for multi select but test 1st.

Edited by BIGAL
  • Like 1
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...