okey dokey pokey, hopefully i have better explained what i'm going for, in the code for the "PolHole" command, i have used the polar command, and i can only get it to work when going from left to right (0 degrees) on my pc.. i checked the "PolarDirection" (user defined) variable which updates flawlessly to whatever angle i pick, but the line doesn't seem to copy and offset the same way...
out of curiousity, i made the code for the "Hole" command., ., same principles, just took out the "polar" command, scaling and hatch.. but i works at all angles..... for my dear life i cannot figure out why the copy and offset are not going to the seemingly defined angle.
Code:
"PolHole" - only works left to right
;;CREATE HOLE SYMBOL IN STEEL CONNECTION PLATE
;-ERROR HANDLER-
(defun *ERROR* (MSG)
(setvar "OrthoMode" OrthoSetting)
(setvar "PolarMode" PolarSetting)
(setvar "CmdEcho" 1)
(princ MSG)
(princ
)
); -END DEFUN *ERROR*
;====================================================================;
; _______ __l_______________________________ or ;
;select l l88l88l to make l select ;
;this Line-> l l88l88l <-hole w/ centerLine l <-this line;
; l_______l88l88l_________ and_______________l ;
; l hatch thru plate ;
;====================================================================;
(Defun C:polhole (/ LineRef OrthoSetting PolarSetting WidthFromCenter DistanceToCenter
StartPoint DifferenceX MidPointX MidPointY CopyPointX
EndPoint StartPointX StartPointY EndPointX EndPointY
DistanceToMidPointX DifferenceY DistanceToMidPointY
MidPoint PolarDirection CopyPoint OffsetPoint2 OffsetPoint1
CopyPointY HatchPointOffset HatchPoint1X HatchPoint2X HatchPoint1Y
HatchPoint2Y HatchPoint1 HatchPoint2 TotalHoleCopyDistance1
HoleCopyPoint
)
(setvar "CmdEcho" 0
)
(while (null
(setq LineRef ;line to make hole from
(car (entsel "n\Pick Line length to reference>:"))))
) ;end while
(setq OrthoSetting (GetVar "OrthoMode")
PolarSetting (GetVar "PolarMode")
WidthFromCenter (/ (GetDist "\nTYPE WIDTH OF HOLE)") 2)
DistanceToCenter(GetDist "\nTYPE DISTANCE TO CENTER OF HOLE:(")
StartPoint (cdr (assoc 10 (ENTGET LineRef)))
EndPoint (cdr (assoc 11 (ENTGET LineRef)))
StartPointX (car StartPoint)
StartPointY (cadr StartPoint)
EndPointX (car EndPoint)
EndPointY (cadr EndPoint)
) ;end setq
;==============================================================;
; begin determine midpoint of LineRef ;
; which is where it will be copied, moved and offset from later;
; (I had trouble working from the startpoint, not sure why, but;
; but working from the midpoint works fine.) ;
;==============================================================;
(if (> EndPointX StartPointX)
(setq DifferenceX (- EndPointX StartpointX))
(setq DifferenceX (- StartpointX EndPointX))) ; end if
(setq DistanceToMidPointX (/ (abs DifferenceX) 2)
)
(if (> EndPointY StartPointY)
(setq DifferenceY (- EndPointY StartPointY))
(setq DifferenceY (- StartPointY EndPointY))) ;end if
(setq DistanceToMidPointY (/ (ABS DifferenceY) 2)
)
;===============================================================;
;this will determine which direction to apply midpoint distances;
;===============================================================;
(cond ((<= StartpointX EndPointX)(SETQ MidPointX (+ StartpointX DistanceToMidpointX)))
((< EndPointX StartpointX)(SETQ MidpointX (+ EndPointX DistanceToMidpointX)))
)
(cond ((<= StartPointY EndPointY)(SETQ MidPointY (+ StartPointY DistanceToMidpointY)))
((< EndPointY StartPointY)(SETQ MidPointY (+ EndPointY DistanceToMidpointY)))
)
(setq MidPoint (LIST MidPointX MidPointY 0.0) ;added z coordinate
)
;end of figuring midpoint
(SETVAR "PolarMode" 2
)
(SETQ PolarDirection (* 180 (/ (GETORIENT "DIRECTION FROM SELECTED LineRef" StartPoint) pi))
CopyPoint (polar MidPoint PolarDirection DistanceToCenter)
OffsetPoint2 (POLAR MidPoint PolarDirection (+ DistanceToCenter WidthFromCenter))
OffsetPoint1 (POLAR MidPoint PolarDirection (- DistanceToCenter WidthFromCenter))
CopyPointX (CAR CopyPoint)
CopyPointY (CADR CopyPoint)
HatchPointOffset 0.09876
HatchPoint1X (+ CopyPointX HatchPointOffset)
HatchPoint2X (- CopyPointX HatchPointOffset)
HatchPoint1Y (+ CopyPointY HatchPointOffset)
HatchPoint2Y (- CopyPointY HatchPointOffset)
HatchPoint1 (List HatchPoint1X HatchPoint1Y)
HatchPoint2 (List HatchPoint2X HatchPoint2Y)
)
;this will create the hole.. hopefully at any angle
(COMMAND "MOVE" LineRef "" MidPoint CopyPoint)
(COMMAND "COPY" LineRef "" CopyPoint MidPoint)
(COMMAND "OFFSET" WidthFromCenter LineRef OffsetPoint1 "E")
(COMMAND "OFFSET" WidthFromCenter LineRef OffsetPoint2 "E")
(COMMAND "SCALE" LineRef "" CopyPoint "1.5")
(COMMAND "-HATCH" "P" "SOLID" HatchPoint1 HatchPoint2 ""
)
(SETQ SsPointsForHole (LIST (LIST (CAR OffsetPoint1)(CADR OffsetPoint1)) ;point list for crossong poly
(LIST (CAR OffsetPoint2)(CADR OffsetPoint2)) ;at midpoints of all 3 lines
(LIST CopyPointX CopyPointY)) ;that make up "Hole"
HOLE (SSGET "_CP" SsPointsForHole)
HoleCopyDistance1 (GETDIST "n\DIST TO NEXT HOLE")
HoleCopyPoint(POLAR CopyPoint PolarDirection HoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint)
;==============================================================================;
;---this just repeats until i find a snazzy way of repeating it an unspecified ;
; number of times ;
;==============================================================================;
(SETQ HoleDistance2 (GETDIST "n\DIST TO NEXT HOLE")
TotalHoleCopyDistance1(+ HoleCopyDistance1 HoleDistance2)
HoleCopyPoint (POLAR CopyPoint PolarDirection TotalHoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint
)
(SETQ HoleCopyDistance1 (GETDIST "n\DIST TO NEXT HOLE")
TotalHoleCopyDistance1(+ HoleCopyDistance1 TotalHoleCopyDistance1)
HoleCopyPoint(POLAR CopyPoint PolarDirection TotalHoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint
)
(SETQ HoleCopyDistance1 (GETDIST "n\DIST TO NEXT HOLE")
TotalHoleCopyDistance1(+ HoleCopyDistance1 TotalHoleCopyDistance1)
HoleCopyPoint(POLAR CopyPoint PolarDirection TotalHoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint
)
(SETQ HoleCopyDistance1 (GETDIST "n\DIST TO NEXT HOLE")
TotalHoleCopyDistance1(+ HoleCopyDistance1 TotalHoleCopyDistance1)
HoleCopyPoint(POLAR CopyPoint PolarDirection TotalHoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint
)
(SETQ HoleCopyDistance1 (GETDIST "n\DIST TO NEXT HOLE")
TotalHoleCopyDistance1(+ HoleCopyDistance1 TotalHoleCopyDistance1)
HoleCopyPoint(POLAR CopyPoint PolarDirection TotalHoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint
)
(SETQ HoleCopyDistance1 (GETDIST "n\DIST TO NEXT HOLE")
TotalHoleCopyDistance1(+ HoleCopyDistance1 TotalHoleCopyDistance1)
HoleCopyPoint(POLAR CopyPoint PolarDirection TotalHoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint
)
(SETQ HoleCopyDistance1 (GETDIST "n\DIST TO NEXT HOLE")
TotalHoleCopyDistance1(+ HoleCopyDistance1 TotalHoleCopyDistance1)
HoleCopyPoint(POLAR CopyPoint PolarDirection TotalHoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint
)
(SETQ HoleCopyDistance1 (GETDIST "n\DIST TO NEXT HOLE")
TotalHoleCopyDistance1(+ HoleCopyDistance1 TotalHoleCopyDistance1)
HoleCopyPoint(POLAR CopyPoint PolarDirection TotalHoleCopyDistance1)
)
(COMMAND "COPY" HOLE "" CopyPoint HoleCopyPoint
)
(SETVAR "PolarMode" PolarSetting)
(SETVAR "OrthoMode" OrthoSetting)
(SETVAR "CmdEcho" 1)
(PRINC)
)
"Hole"- not what i want but works at all angles with about the same variable values..
Code:
;;CREATE HOLE SYMBOL IN STEEL CONNECTION PLATE
;-ERROR HANDLER-
(defun *ERROR* (MSG)
(setvar "OrthoMode" OrthoSetting)
(setvar "PolarMode" PolarSetting)
(setvar "CmdEcho" 1)
(princ MSG)
(princ
)
); -END DEFUN *ERROR*
(Defun C:hole (/ LineRef PolarSetting WidthFromCenter DistanceToCenter StartPoint
EndPoint StartPointX StartPointY EndPointX EndPointY DifferenceX
DistanceToMidPointX DifferenceY DistanceToMidPointY MidPointX MidPointY
MidPoint PolarDirection OppPolarDirection HoleSide CopyDist CopyDeg
OppCopyDeg Side1 Side2 MoveStr CopyStr1 HoleSide1Str)
(setvar "CmdEcho" 0
)
(while (null
(setq LineRef (car (entsel "<Pick Line length to reference>:"))));line to make hole from
) ;end while
(setq PolarSetting (GetVar "PolarMode")
WidthFromCenter (/ (GetDist "\nTYPE WIDTH OF HOLE)") 2) ;hole variables
DistanceToCenter (GetDist "\nTYPE DISTANCE TO CENTER OF HOLE:(")
StartPoint (cdr (assoc 10 (ENTGET LineRef)));"LineRef" points
EndPoint (cdr (assoc 11 (ENTGET LineRef)))
StartPointX (car StartPoint)
StartPointY (cadr StartPoint)
EndPointX (car EndPoint)
EndPointY (cadr EndPoint)
) ;end setq
(if (> EndPointX StartPointX) ;if "LineRef" moves right from StartPoint
(setq DifferenceX (- EndPointX StartpointX)) ;do this... if it moves left
(setq DifferenceX (- StartpointX EndPointX)) ;do this
) ;end if
(setq DistanceToMidPointX (/ (abs DifferenceX) 2) ;get mid of absolute difference in "x"
)
(if (> EndPointY StartPointY) ;if "LineRef" moves up from StartPoint
(setq DifferenceY (- EndPointY StartPointY)) ;do this... if it moves down
(setq DifferenceY (- StartPointY EndPointY)) ;do this
) ;end if
(setq DistanceToMidPointY (/ (ABS DifferenceY) 2) ;get mid of absolute difference in "y"
)
;this will determine which direction to apply midpoint distances
(cond ((<= StartpointX EndPointX)(SETQ MidPointX (+ StartpointX DistanceToMidpointX)))
((< EndPointX StartpointX)(SETQ MidpointX (+ EndPointX DistanceToMidpointX)))
)
(cond ((<= StartPointY EndPointY)(SETQ MidPointY (+ StartPointY DistanceToMidpointY)))
((< EndPointY StartPointY)(SETQ MidPointY (+ EndPointY DistanceToMidpointY)))
)
(setq MidPoint (LIST MidPointX MidPointY 0.0)
);-------------------------------------------end of figuring midpoint
(SETVAR "PolarMode" 2 ;polar on to determine direction to make hole
)
;=================================================================================;
;here is a work around for my faulty polar section of my first code, i have ;
;left out the hatching, and the scaling of the centerline in this code. this is ;
;to show an idea of what i would like the "polar" command to do in the first code ;
;which is to create the "holes" at any angles my little heart desires. ;
;=================================================================================;
(setq PolarDirection(* 180(/ (GETORIENT "DIRECTION FROM SELECTED Line" StartPoint) pi))
OppPolarDirection (- PolarDirection 180)
HoleSide (RtoS WidthFromCenter 2)
CopyDist (RtoS DistanceToCenter 2)
OppCopyDeg(RtoS OppPolarDirection 2)
CopyDeg (RtoS PolarDirection 2)
Side1 (RtoS HoleSide1 2)
Side2 (RtoS HoleSide1 2)
MoveStr (StrCat "@" copydist "<" CopyDeg)
CopyStr1 (StrCat "@" copydist "<" OppCopyDeg)
HoleSide1Str (StrCat "@" HoleSide "<" CopyDeg)
HoleSide2Str (StrCat "@" HoleSide "<" OppCopyDeg)
)
(command "move" LineRef "" MidPoint movestr)
(command "copy" LineRef "" MidPoint copystr1)
(command "copy" LineRef "" MidPoint HoleSide1Str)
(command "copy" LineRef "" MidPoint HoleSide2Str)
;=================================================================================;
;then i would like to scale the middle line to *1.25 and hatch in between the ;
;outer-most lines, then copy or repeat for multiple "hole" instances ;
;=================================================================================;
(SETVAR "PolarMode" PolarSetting) ;reset polar
(setvar "CmdEcho" 1)
);end defun hole
two thousand thanks and endless gratitude to anyone who knows what in the infernal hades i have done... yes, i even renamed the "POO"
Bookmarks